MenuItemClick not firing if programmatically changing selected itemon a Menu Control

A

adiel_g

Hello, if you programmatically change the selected menu item (as
opossed to the user clicking on a menu item) on a ASP.NET 2.0 Menu
control as follows:

Menu Control:
<asp:Menu ID="mnuActions"....

Code to programmatically change the selected menu item:
Dim mi As MenuItem = Me.mnuActions.FindItem("Customers")
mi.Selected = True

The above code will not fire the MenuItemClick event. (This was
expected since the user did not click on the item)

My question is, is there another event that will detect when the
selected menu item was programmatically changed?

Thanks Before Hand,
Adiel
 
P

Peter Bucher [MVP]

Hi Adiel
Code to programmatically change the selected menu item:
Dim mi As MenuItem = Me.mnuActions.FindItem("Customers")
mi.Selected = True

The above code will not fire the MenuItemClick event. (This was
expected since the user did not click on the item)
This is the expected behavior.
Theres no user interaction, theres no event fireing.

Do fire your event manually or do your stuff right on that place you set
the item to "selected = true".
My question is, is there another event that will detect when the
selected menu item was programmatically changed?
no
 
S

Stan

Hello, if you programmatically change the selected menu item (as
opossed to the user clicking on a menu item) on a ASP.NET 2.0 Menu
control as follows:

Menu Control:
<asp:Menu ID="mnuActions"....

Code to programmatically change the selected menu item:
    Dim mi As MenuItem = Me.mnuActions.FindItem("Customers")
    mi.Selected = True

The above code will not fire the MenuItemClick event. (This was
expected since the user did not click on the item)

My question is, is there another event that will detect when the
selected menu item was programmatically changed?

Thanks Before Hand,
Adiel

Dear Adiel

Events are normally triggered by user activity on the client, by the
host system external to the application, autonomous routines within
the application (example page loading) or other entities (e.g.
asynchronous communications) that are not under direct control of the
application itself.

That is the sole purpose of them. Anything that is done
programatically using code written by the developer is controlled and
handled by the code itself and at the time of its execution.

It makes no sense to require "detection" of programmatic changes in
event handlers.

HTH
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top