GlobaLevel
asked on
asp.net - session varaible error in asp:menu control
I get an error...Session("sessionho me_page"
instead of this:
<asp:MenuItem NavigateUrl="~/Local Control Panel.aspx" Text="Local Control Panel" Value="Local Control Panel">
</asp:MenuItem>
I want to do this:
<asp:MenuItem Session("sessionhome_page" )>
</asp:MenuItem>
instead of this:
<asp:MenuItem NavigateUrl="~/Local Control Panel.aspx" Text="Local Control Panel" Value="Local Control Panel">
</asp:MenuItem>
I want to do this:
<asp:MenuItem Session("sessionhome_page"
</asp:MenuItem>
Hi GlobaLevel,
Perhaps you may want to store just the URL:
<asp:MenuItem NavigateUrl='Session("sess ionhome_pa ge_url")' Text="Local Control Panel" Value="Local Control Panel" />
Or break them up into 3 different variables so that you can use:
<asp:MenuItem NavigateUrl='Session("sess ionhome_pa ge_url")' Text='Session("sessionhome _page_text ")' Value='Session("sessionhom e_page_val ue")' />
Perhaps you may want to store just the URL:
<asp:MenuItem NavigateUrl='Session("sess
Or break them up into 3 different variables so that you can use:
<asp:MenuItem NavigateUrl='Session("sess
ASKER
Alphaau... Can you give an example? I'm using master pages
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi!
Sorry for the wrong code posted, please view the modified code below:
<asp:MenuItem NavigateUrl='<%# Session("sessionhome_page_ url") %>' Text="Local Control Panel" Value="Local Control Panel" />
Or break them up into 3 different variables so that you can use:
<asp:MenuItem NavigateUrl='<%# Session("sessionhome_page_ url") %>' Text='<%# Session("sessionhome_page_ text") %>' Value='<%# Session("sessionhome_page_ value") %>' />
Sorry for the wrong code posted, please view the modified code below:
<asp:MenuItem NavigateUrl='<%# Session("sessionhome_page_
Or break them up into 3 different variables so that you can use:
<asp:MenuItem NavigateUrl='<%# Session("sessionhome_page_
ASKER
I like this....but I have to add it to every page where this a menu item....... I was hoping with the session varabile just have it on one page the code behind
assume you define a menu in the aspx
<asp:Menu runat="server" ID="Mnutest"></asp:Menu>
in the code behind, you can add the following in Page_Load
MenuItem tmpitem = new MenuItem();
tmpitem.Text = Session["sessionhome_page_
tmpitem.Value = Session["sessionhome_page_
tmpitem.NavigateUrl = Session["sessionhome_page_
this.Mnutest.Items.Add(tmp
you can put it on the master page code behind
the only problem is when will you assign the session variable value?
the only problem is when will you assign the session variable value?
ASKER
I have a main page that is set as the start page...when the site opens all the session varaibles are set on this page then as other pages are open...the varaibles are already set...
can you put the menu in the master page?
if so, you can put the code behind in master page code behind too
if so, you can put the code behind in master page code behind too
menu.additem new menuItem(Session["sessionh