NewFromMattel
Programmer
I'm learning .Net (C#) and trying to implement some code in ASP.Net. My goal is to gain understanding by replicating some functions that I can do in coldfusion.
Here's what I'm doing. Building a very basic menuing control so that Default.aspx?index=2 will show a menu tab highlighted, and so on. And the menu tabs are built and driven (by a datalist) from an arraylist. So I initialize the arraylist, and then add items to it via a class that uses get and set accessors (that I don't really understand yet, but I'm trying).
Then I bind the datalist to the arraylist. Then the datalist accesses the elements of the arraylist and derives "Name" and "Path" successfully. I've built this from pieces here and there (especially the quickstart tutorials, and the Time tracker starter kit). But now I'm "freelancing" trying to access the arraylist and get the name out. But I just can't get it. So here's what I've got. (limited the coding pasted to shorten the post)
public MyTabItem(string newName, string newPath) // call the MyTabItem method with the vars
{
_name = newName;
_path = newPath;
}
public string Name
{
get { return _name;}
set { _name = value;}
}
public string Path
{
get { return _path; }
set { _path = value; }
}
thenin the page_load
ArrayList menuItems = new ArrayList();
menuItems.Add(new MyTabItem("Work History", "?index=" + menuItems.Count));
menuItems.Add(new MyTabItem("Past Accomplishments", "?index=" + menuItems.Count));
menuItems.Add(new MyTabItem("References", "?index=" + menuItems.Count));
MyDataList.DataSource = menuItems;
MyDataList.DataBind();
int urlSelection = (Request["index"]==null) ? 0 : Convert.ToInt32(Request["index"]);
MyDataList.SelectedIndex = urlSelection;
here is the datalist guts (the hyperlink control for the actual tab
<asp:HyperLink id=HyperLink1 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name" %>' NavigateUrl='<%# Request.Path + DataBinder.Eval(Container.DataItem, "Path", "{0}" %>'>
</asp:HyperLink>
Now what I want to do is somewhere else on the page, just have a label and set the text of the label to equal the "Name" of the part of the arraylist element.
This is all a learning process. I've learned a lot thus far, and any help at all will be appreciated.
TIS
NewFromMattell
Here's what I'm doing. Building a very basic menuing control so that Default.aspx?index=2 will show a menu tab highlighted, and so on. And the menu tabs are built and driven (by a datalist) from an arraylist. So I initialize the arraylist, and then add items to it via a class that uses get and set accessors (that I don't really understand yet, but I'm trying).
Then I bind the datalist to the arraylist. Then the datalist accesses the elements of the arraylist and derives "Name" and "Path" successfully. I've built this from pieces here and there (especially the quickstart tutorials, and the Time tracker starter kit). But now I'm "freelancing" trying to access the arraylist and get the name out. But I just can't get it. So here's what I've got. (limited the coding pasted to shorten the post)
public MyTabItem(string newName, string newPath) // call the MyTabItem method with the vars
{
_name = newName;
_path = newPath;
}
public string Name
{
get { return _name;}
set { _name = value;}
}
public string Path
{
get { return _path; }
set { _path = value; }
}
thenin the page_load
ArrayList menuItems = new ArrayList();
menuItems.Add(new MyTabItem("Work History", "?index=" + menuItems.Count));
menuItems.Add(new MyTabItem("Past Accomplishments", "?index=" + menuItems.Count));
menuItems.Add(new MyTabItem("References", "?index=" + menuItems.Count));
MyDataList.DataSource = menuItems;
MyDataList.DataBind();
int urlSelection = (Request["index"]==null) ? 0 : Convert.ToInt32(Request["index"]);
MyDataList.SelectedIndex = urlSelection;
here is the datalist guts (the hyperlink control for the actual tab
<asp:HyperLink id=HyperLink1 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name" %>' NavigateUrl='<%# Request.Path + DataBinder.Eval(Container.DataItem, "Path", "{0}" %>'>
</asp:HyperLink>
Now what I want to do is somewhere else on the page, just have a label and set the text of the label to equal the "Name" of the part of the arraylist element.
This is all a learning process. I've learned a lot thus far, and any help at all will be appreciated.
TIS
NewFromMattell