Advertisement

08.25.2008 at 11:11AM PDT, ID: 23676064
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Set value of control after a redirect

Asked by dba123 in Programming for ASP.NET

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/AdminTabEnabled.jpg"; 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.jpg";

            switch (e.Item.Value)
            {
                case "0":
                    //Response.Redirect("~/Default.aspx?");
                    Menu1.Items[0].ImageUrl = "~/App_Themes/xxx/Images/HomeTabEnabled.jpg";
                    break;
                case "1":
                    //Response.Redirect("~/Admin/Default.aspx?admin=1");
                    Menu1.Items[1].ImageUrl = "~/App_Themes/xxx/AdminTabEnabled.jpg";
                    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_master myMaster = (ASP.masterpages_admin_master)this.Page.Master;
            Menu masterMenu = (Menu)Page.Master.FindControl("Menu11");
            masterMenu.Items[1].ImageUrl = "~/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
[+][-]08.26.2008 at 07:34AM PDT, ID: 22315163

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Sign Up Now!
Solution Provided By: Rejojohny
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.04.2008 at 07:15PM PDT, ID: 22643038

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10.06.2008 at 07:57AM PDT, ID: 22650702

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628