Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Contributor
6455 Points
1187 Posts
Apr 18, 2012 02:38 PM|LINK
Change your navigation code by creating HtmlGenericControls instead of adding text to a Literal:
List<Navigation> theNavigation = DataHelper.GetNavigation(); theNavigation = theNavigation.OrderBy(u => u.OrderBy).ToList(); foreach (Navigation item in theNavigation) { HtmlGenericControl li = new HtmlGenericControl("li"); li.ID = item.TabName; li.Style.Add("display", item.Display); li.InnerText="><span><a href......."; ...... yourUl.Controls.Add(li); }
..and define a UL in your markup to hold the HtmlGenericControls you are creating in code:
<ul runat="server" id="yourUl"> </ul>
mm10
Contributor
6455 Points
1187 Posts
Re: Object Error with HtmlGenericControl
Apr 18, 2012 02:38 PM|LINK
Change your navigation code by creating HtmlGenericControls instead of adding text to a Literal:
List<Navigation> theNavigation = DataHelper.GetNavigation();
theNavigation = theNavigation.OrderBy(u => u.OrderBy).ToList();
foreach (Navigation item in theNavigation)
{
HtmlGenericControl li = new HtmlGenericControl("li");
li.ID = item.TabName;
li.Style.Add("display", item.Display);
li.InnerText="><span><a href.......";
......
yourUl.Controls.Add(li);
}
..and define a UL in your markup to hold the HtmlGenericControls you are creating in code:
<ul runat="server" id="yourUl">
</ul>