Click to See Complete Forum and Search --> : Problem With using Menus in Asp.net?


roxcy
10-06-2006, 08:08 AM
Hi,
I am working on a WebSite Where i am using Menus.Now The problem is When I click on a Particular Item in a Menu.
For eg Details is the name of the Menu and Under Details I Have StudentDetails,TeacherDetails,InstitutionDetails.Now when I Click on for eg Student details on the menu I do Get the required form,But the Menu disappears on that very form ie Only Details appears on the Menu Bar.If I want to now check for TeacherDetails I have to press Back button.And the Same process has to be repeated everytime I logon.Following is my javascript path where it is stored.


_page.items["0"] = new _Item("Home", "/AMC/UserHome.aspx")
_page.items["1"] = new _Item("Admin","#")
_page.items["2"] = new _Item("Details", "#")
_page.items["2_1"] = new _Item("StudentDetails", "/AMC/Masters/frmMstStudentDetails.aspx")
_page.items["2_2"] = new _Item("TeacherDetails ", "/AMC/Masters/frmMstTeacherDetails.aspx")
_page.items["2_3"] = new _Item("InstitutionDetails","/AMC/Masters/frmMstInstitutionDetails.aspx")



Plz Help me out with a solution...
Thanks in Advance....

sirpelidor
10-06-2006, 01:28 PM
when I Click on for eg Student details on the menu I do Get the required form,But the Menu disappears on that very form ie Only Details appears on the Menu Bar.If I want to now check for TeacherDetails I have to press Back button.And the Same process has to be repeated everytime I logon.Following is my javascript path where it is stored.


does your sub menu generate by javascript based on the click of the main menu? if so, whenever you click something on ASP.NET, the entire page get postback. And all your non-.net controls (i.e javascript) will lost the pervious state. That's why your sub-menu disappear because it lost its state.

roxcy
10-09-2006, 01:39 AM
Yeah Exactly,
So what should the solution would be like.Since I have already use If not Page.IsPostBack = true in the Page Load Event of the Form.

sirpelidor
10-09-2006, 12:58 PM
i think you have 2 obvious choices, to use javascript, or not to use javascript.

if you want to keep using javascript, you'll ways to retain the state. Maybe through cookie or httpget?

so if the user click the main menu, instead of just displaying the sub-menu, you would probably insert a code like:
document.cookie = "displayMenu=true";

when displaying your sub menu, you probably need to check the cookie before displaying....

if you choose not to use javascript, you can use the panel control from asp.net. Put the sub-menu inside the panel control, and set panel.display = false when it is not post back, and set it to true after post back. That should do the trick.