bharadwajrv
May 23rd, 2007, 06:23 AM
I'm using 'User Controls' to define the 'Page header' for every webpages...
In User Control - there is a DataList control to display the site-navigation-links (i.e. Home, About us, Contact us)...
In 'ascx' page of the user control -
<ItemTemplate> is used to define the links within the <asp:table> control... After DataBind() is done, i wanted to change the "Cssclass" value of "Table"...
but i'm getting below error message, what wrong with code.. ??
Basically, i'm trying to achieve making the 'tab like' structure and indicating 'Active' and 'Inactive' tabs
(project is attached - "Fixtures.aspx" implements above logic )
Thanks in adv.
Error message
System.NullReferenceException: Object reference not set to an instance of an object
ascx code
<ItemTemplate>
<asp:Table ID=tHeader Runat=server>
<asp:TableRow Runat=server ID=rHeader>
<asp:TableCell Runat=server ID=cHeader>
<asp:HyperLink ID="lnkTabs" Runat="server"
text='<%#DataBinder.Eval(Container.DataItem, "Name")%>'
NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "Url")%>'>
</asp:HyperLink>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
page behind code
private void Page_Load(object sender, System.EventArgs e)
{
:
DataList1.DataBind();.....
:
TableCell tc = (TableCell )Page.FindControl("cHeader");
tc.CssClass = "InactiveTab";
:
}
In User Control - there is a DataList control to display the site-navigation-links (i.e. Home, About us, Contact us)...
In 'ascx' page of the user control -
<ItemTemplate> is used to define the links within the <asp:table> control... After DataBind() is done, i wanted to change the "Cssclass" value of "Table"...
but i'm getting below error message, what wrong with code.. ??
Basically, i'm trying to achieve making the 'tab like' structure and indicating 'Active' and 'Inactive' tabs
(project is attached - "Fixtures.aspx" implements above logic )
Thanks in adv.
Error message
System.NullReferenceException: Object reference not set to an instance of an object
ascx code
<ItemTemplate>
<asp:Table ID=tHeader Runat=server>
<asp:TableRow Runat=server ID=rHeader>
<asp:TableCell Runat=server ID=cHeader>
<asp:HyperLink ID="lnkTabs" Runat="server"
text='<%#DataBinder.Eval(Container.DataItem, "Name")%>'
NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "Url")%>'>
</asp:HyperLink>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
page behind code
private void Page_Load(object sender, System.EventArgs e)
{
:
DataList1.DataBind();.....
:
TableCell tc = (TableCell )Page.FindControl("cHeader");
tc.CssClass = "InactiveTab";
:
}