Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 ASP.NET C# Masterpage and Contentpage
Posted by Jim Sotto Rosacena on  5/13/2012 1:55:17 AM Category: C#
Add to my favorites
Email to friend
Dear Guys,

I am really frustrated these few days. I'm kinda new to and c# as my code behind. i wish somebody could help me.

I am created a Masterpage. The page itself contains two different menu items separately. 1 is Main Menu (<asp:menuitem id:mainmenu>) and the 2nd is Side Menu (<asp:sidemenu id:sidemenu>). I also have contentplaceholder (<asp:ContentPlaceHolder ID=MainContent>). My menu items are dynamic since datas are pulled from a table. At first run (ispostback=false), all contents are in place with no problem. Datas in side menu are dependent to the content of my main menu. most of them are coded thru the code behind.
Hierarchy of my menu goes like this:
- Department 1 (dept1.aspx)
- Department 2 (dept2.aspx)
- Books (books.aspx)
- Watches (watches.aspx)
- Pens (pens.aspx)
- Services (services.aspx)

Here's the problem now:
When i click the 2nd option main menu (which contains products), it will enlist all products. When i click any products in my side menu (example watches), it calls an specific contentpage to a main contentplaceholder (watches.aspx). the problem is, after loading all the contents in the contentplaceholder, the ispostback will switch to false again and all my datas in my menuitem are also empty as if i'm running it again at the first time. so, it will reset all again as if i am loading the page like first time. so, basically, all of the datas in menu items will be resetted.
i am struggling on this for weeks now.

i really appreciate your help and advices as a solution to my problem. i wish my explanation are clear. Please tell me also if the approach of my programming is wrong and what is the best solution for it.

Thank you very much.


Post Your Reply Post New Question

 Viewer's Reply
dynamic Menu Disappears on Postback
Answered By Moderator1 on 9/11/2012 10:03:27 AM
Hi Jim,

Menu controls are stateless. So, make sure the ViewState property is true. Otherwise, keep the menu data in a view state in code-behind and bind the menu control, every time you postback the page.
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
The Beginner's Guide to Joomla
Backup and Recovery Best Practices for Microsoft SQL Server 2005
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview