Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > StaticItemTemplate is not applied on postback Options

Reply
Thread Tools

StaticItemTemplate is not applied on postback Options

 
 
John123
Guest
Posts: n/a
 
      10-30-2007
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://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<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="http://www.w3.org/1999/xhtml" >
<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>

 
Reply With Quote
 
 
 
 
John123
Guest
Posts: n/a
 
      11-01-2007
On Oct 30, 2:27 pm, John123 <(E-Mail Removed)> wrote:
> 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://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <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="http://www.w3.org/1999/xhtml" >
> <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>


noone???

 
Reply With Quote
 
 
 
 
beemer127
Guest
Posts: n/a
 
      12-19-2007
On Oct 30, 8:27 am, John123 <(E-Mail Removed)> wrote:
> 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://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <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="http://www.w3.org/1999/xhtml" >
> <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>


I am having the same problem. I found a workaround, but not a
solution. Basically, I was using an image button. instead of using the
postback property, I simply did a response.redirect() in the code
behind (VB.NET). Unfortunately, that does not fix the problem,
especially when you may be working with data-driven forms requiring a
postback. I'm not sure what else to do at this point, so if you have
found a solution, please let me know. )
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu control Databinding problem using StaticItemTemplate Andrew Jocelyn ASP .Net 3 01-17-2008 08:33 AM
StaticItemTemplate is not applied on postback John123 ASP .Net 1 11-06-2007 03:35 PM
Specifying style for subitems in the ASP Menu StaticItemTemplate =?Utf-8?B?QUMgW01WUCBNQ01TXQ==?= ASP .Net 0 11-15-2006 09:30 PM
ASP.NET v2 Menu StaticItemTemplate benjamin.soulier@gmail.com ASP .Net 0 07-22-2005 12:43 PM
How to use a StaticItemTemplate? Ilmar ASP .Net 2 08-15-2004 01:42 PM



Advertisments