Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ASP .Net Web Controls
StaticItemTemplate is not applied on postback Options
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="John123, post: 4309089"] Hi all, I am having a strange problem when using the ASP.NET (2.0) menu control. I have a menu control that gets populated in the page load. I do not check the PostBack value because I want to rebuild the Menu Control each page visit. The first time the Menu is built exactly as specified in the StaticItemTemplate, however, each pressing the postback button gives me an un-staticitemtemplated version of the menu. IOW on postback and rebuild of the menu, the itemtemplate (and thus styling) is removed or not even applied. Can anyone help??? Here is the code to reproduce: <%@ Page Language="C#" %> <%@ Register Src="UserControls/Menu.ascx" TagName="Menu" TagPrefix="uc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// [URL="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Menu1.Items.Clear(); Menu1.Items.Add(new MenuItem("hello world1")); Menu1.Items.Add(new MenuItem("hello world2")); Menu1.Items.Add(new MenuItem("hello world3")); Menu1.Items.Add(new MenuItem("hello world4")); } </script> <html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Menu ID="Menu1" runat="server"> <StaticItemTemplate> <asp:Button ID="Button1" runat="server" Text='<%# Eval("Text") %>' /> </StaticItemTemplate> </asp:Menu> <asp:Button runat="server" ID="btnButton" Text="Do a postback to rebuild the menu" /> </div> </form> </body> </html> [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASP .Net Web Controls
StaticItemTemplate is not applied on postback Options
Top