I commented out the redirects here and the setting of the ImageURL works fine. Problem: As soon as I introduce those redirects, all is lost in the page I redirect to, and the Image is not set for the menu control.
Why and how do I persist this on lets say either of t he default.aspx pages I'm trying to redirect to? I also need to be able to grab reference to the Menu control itself so I can maybe somehow do a Menu1.Items[1].ImageUrl = "~/App_Themes/xxx/AdminTab
Enabled.jp
g"; once I get to default.aspx? Seems like a bunch of hell to me just to get the image to stay.
The code. This is in my master page's code behind. My Main.master holds the control and this is where I try to tell it to set the image after redirect.
public void Menu1_MenuItemClick(Object
sender, MenuEventArgs e)
{
if (Page.IsPostBack)
{
Menu1.Items[0].ImageUrl = "~/Images/HomeDisabled.jpg
";
Menu1.Items[1].ImageUrl = "~/Images/AdminDisabled.jp
g";
switch (e.Item.Value)
{
case "0":
//Response.Redirect("~/Def
ault.aspx?
");
Menu1.Items[0].ImageUrl = "~/App_Themes/xxx/Images/H
omeTabEnab
led.jpg";
break;
case "1":
//Response.Redirect("~/Adm
in/Default
.aspx?admi
n=1");
Menu1.Items[1].ImageUrl = "~/App_Themes/xxx/AdminTab
Enabled.jp
g";
break;
}
}
}
I've tried to do something like this in the Default.aspx.cs (the page I'm redirecting to) but no luck:
--------------------------
----------
----------
----------
----------
----------
-----
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Admin"] == "1")
{
ASP.masterpages_admin_mast
er myMaster = (ASP.masterpages_admin_mas
ter)this.P
age.Master
;
Menu masterMenu = (Menu)Page.Master.FindCont
rol("Menu1
1");
masterMenu.Items[1].ImageU
rl = "~/Images/AdminTabEnabled.
jpg";
}
}
Note: I did expose the menu control as a property in my Main.master.cs so that I could reference it in the Default.aspx.cs but it blows up at runtime saying a null reference exception. There must be a much more easier/logical way to handle persisting the image and I've spent a day on this problem already.
Start Free Trial