OnClick event for a menu item?

Answered (Verified) This post has 1 verified answer and 1 reply

Not Ranked
Posts: 1
bportela Posted: Sat Dec 19, 2009 @ 3:17 PM
I'm not sure if this has been convered in this forum, but I gave it a quick look with no avail.

Essencially for some inherited reasons I've decided to replace a whole bunch of buttons I had in my app for a Menu, which will have an item for each of the buttons I used to have.

The problem is that my whole app is programed in such a manner that each button fired a different function instead of loadig a new place.

I'm wondering if there's anyway to assign each menu item a OnClick event on creation time...

appreciate the help,
Bruno.

Answered (Verified) Verified Answer

Top 10 Contributor
Posts: 865
Answered (Verified) sberkovitz Posted: Sun Dec 20, 2009 @ 4:37 PM
Verified by bportela

The MenuItem class does not contain any server-side events.  Instead you can set the AutoPostBackOnSelect property on the Menu to true, and handle the ItemSelected event.  The originating MenuItem is provided via the MenuItemEventArgs.Item property.

As a quick "shim" to your current code, you'll need to use a switch/if-else statement in the ItemSelected event to identify the sender and redirect to the correct handler.

Steven Berkovitz MBC Development Ltd. & OrderDynamics Corporation http://www.mbccs.com http://www.orderdynamics.com
Page 1 of 1 (2 items)