menu postback not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My asp.net 2005 menu control has items with nothing in navigateUrl - meaning
it should postback when an item is selected. I have code in the Page_Load
which is supposed to call a method based on the selected menu item.

if (this.Menu1.SelectedItem.Value.Equals("1"))
processA();
if (this.Menu1.SelectedItem.Value.Equals("2"))
processB();

This does not work the first time the menu item is selected. It does work
the second time the menu item is selected.
I guess I STILL do not understand postback. Shouldn't this work for the
first selection?
Thanks
 
set the autopostBack = true on the Menu control. Also you should put the
posted code in the Menu1_Click event.
 
I do not see an autopostBack either throught the property sheet or though the
object. Also, I must have the menu selected item value in the Page_Load as
it is here that I must know which of my load routines to call (not in the
click event).
Any help is greatly appreciated.
 
What kind of MenuControl are you using? Why do you need to run that code on
the Page_Load, when you need the user to click something anyways

It would be better to use:

void Page_Load(sender, e)
{
if (!Page.IsPostBack)
ProcessDefault();
}

void Menu1_Click(sender, e)
{
if (this.Menu1.SelectedValue.Value == "1")
ProcessA();
if (this.Menu1.SelectedValue.Value == "2")
ProcessB();
}
 
The menu control is the standard menu control selected from the navigation
list of controls from the toolbox in VS 2005.
I must have the selected value in page_load because it is a report choice
and I must know what report they are requesting. I can only build the report
at load time (as I understand it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top