Additional ASP Menu Not Updating On Postback

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/5/2012 11:14:08 AM
Gravatar
Total Posts 148

Additional ASP Menu Not Updating On Postback

Hi:

I have a home page Home.aspx. I added a button to the layout.Master under my skins folder.  This button will post back to the Home.aspx page.  I simply set the "PostBackUrl="~/Home.aspx"  I also installed an <asp:Menu> control at the top of the Home.aspx page.  This menu is in addition to the <portal:SiteMenu>. My <asp:Menu> control references an XML file for it's data.

When I select the <portal:SiteMenu> "Home" tab, while on another page, my menu will update and show the correct items in the menu. Everything is fine so far. 

Now, if I click the button while I'm on another page, the correct page will show in the address bar, and in fact show the correct page as well, but the menu on the page will not update to show the current items.  It appears to still be showing the menu items form the previous page.

This problem does not surface if I select the <portal:SiteMenu> "Home" tab. Only if I browse to the home page, from another page, through the image button.

I read on this site that I should set Page.EnableViewState to true on the page load but I tried that in the layout.Master under the MasterPages folder and it still didn't work.

1/5/2012 12:59:03 PM
Gravatar
Total Posts 18439

Re: Additional ASP Menu Not Updating On Postback

why do you want to post back to the home page vs just linking to it? My advice is don't make unneccesary postbacks just use a link. postback is for submitting forms not for navigation.

1/6/2012 9:39:17 AM
Gravatar
Total Posts 148

Re: Additional ASP Menu Not Updating On Postback

Hi:

I set EnableViewState=False on the  asp:Menu control and now it works.

1/6/2012 10:30:46 AM
Gravatar
Total Posts 18439

Re: Additional ASP Menu Not Updating On Postback

Thats good it will reduce uneeded viewstate in the page and reduce the payload size, but you still should not use postback for no reason, ie use a link with an image instead of an imagebutton with a postback url.

postback is for submitting forms. Consider what happens when a user clicks your button and it posts to your home page, now it is in a posted state and what happens if the user clicks the browser refresh button? It will prompt the iuser "do you want to resubmit the form" instead of the expected behavior of just refresh the page.

The typical pattern used when processing forms is to redirect out of postback after processing the form so that this browser refresh problem does not happen and forms don't get submitted twice accidently.

postback does a post request and regular links do a get request, normal navigation should be done by get requests.

You must sign in to post in the forums. This thread is closed to new posts.