473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

menu postback not working

Jay
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
--
Jay
Dec 19 '05 #1
5 2684
set the autopostBack = true on the Menu control. Also you should put the
posted code in the Menu1_Click event.
Dec 19 '05 #2
Jay
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.
--
Jay
"Ben Dewey" wrote:
set the autopostBack = true on the Menu control. Also you should put the
posted code in the Menu1_Click event.

Dec 19 '05 #3
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();
}
Dec 19 '05 #4
Jay
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).
--
Jay
"Ben Dewey" wrote:
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();
}

Dec 19 '05 #5
Jay
Thanks much to Ben. I re-sequenced my test case and it worked--
Jay
"Jay" wrote:
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).
--
Jay
"Ben Dewey" wrote:
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();
}

Dec 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fuehner | last post by:
I have a masterpage define that contains a asp:menu control. My menu control has items that do not have a NavigateUrl assigned which causes them to postback on the current page... Now the issue...
9
by: Jay | last post by:
I have an asp menu control with menu items navigateUrl set to come back to the same aspx page but with different values in a url token. this works, but it is causing all my asp controls to loose...
1
by: Abdalla | last post by:
Dear All I have a project on making a UI of a Web page that allows users to: 1. select any text by highlighting it, and 2. do some action on it by right-clicking on the highlighted text and...
11
by: Rickie | last post by:
Dear fellow software engineers, Is the web menu in asp 2.0 essentielle a useless control ? How many people( including msdn itself) are using server menu controls? Its a menu which always...
0
by: John Smith | last post by:
If anyone can help, I would very muchly appreciate it. I have a main page that uses the .net 2.0 menu control with the multiview controls as the menu choices. This works fine. One of the menu...
6
by: clintonG | last post by:
I haven't learned this control yet but I do need to know if it can be configured to drop down instead of fly-out? // Like this... ------------------- Static Root Label -------------------...
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
0
by: MikeB | last post by:
Hello All, I have UserControl that consists of a Menu control. When a user selects an item in the Menu I set a Public variable in the MenuItemClick event. My problem is that when the main...
5
by: AG | last post by:
I realize that the obvious suggestion would be malware, but my definitions are up to date and I have already scanned for it. I have also tried disabling all IE add-ons. I just rebuilt and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.