Menu item postback

To call a server event after you click on menu item you need to use,
as you can see inside the suite example, an invisible button:
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" style="display:none" />

Also a helpful control is a hidden input for storing the id of the clicked menu item:
<input type="hidden" id="Hidden1" runat="server" />

The server event that is called is the event that is triggered when the button is clicked
(currently not allowed because is not visible):
protected void Button1_Click(object sender, EventArgs e)
{
    ...some code...
}

The last important thing is the client event triggered by the menu item.
The event is set using menu item server property "OnClientClick":
<oem:MenuItem InnerHtml="<b>Server event 1</b>" ID="menuItem2" OnClientClick="CallServerEvent('menuItem2')"></oem:MenuItem>

Client-side event

function CallServerEvent(argument)
{
    // store the clicked item id
    document.getElementById('<%=Hidden1.ClientID %>').value = argument;
    // call the server side event (same as button click)
    <%= Page.ClientScript.GetPostBackEventReference(this.Button1, "") %>
}

Mouse over the gray box to see the menu.
Clicking on the second and third item in the menu will cause a postback to server.

 
 




Download Download this working example.

"The flyout does work great. You have some pretty nifty components I cannot live without. Thank you again very much for your support and timely responses."

Jennifer

obout.com
obout.com Home
News New
EasyMenu Home 
What Is EasyMenu
Download
Site Map
Compare with TextMenu
Examples - 47
Horizontal - 14
Horizontal 1
Horizontal 2
Horizontal 3
Horizontal 4
Horizontal 5
Horizontal 6
Horizontal 7
Horizontal 8
Horizontal Right To Left
Transparent - over flash
Transparent - over iframe
MSDN
MSDN 2
With rounded corners
Vertical - 3
Vertical 1
MS Vertical
Vertical Right To Left
Context Menu - 10
World Map
Default
Futura
VSNET
Windows
WindowsXP
Style 1
Style 2
Style 3
Right To Left
Tabstrip - 19
Tab Strip
Tab Strip - With postback New
Different Styles - 13
TabStrip1
TabStrip2
TabStrip3
TabStrip4
TabStrip5
TabStrip6
TabStrip7
TabStrip8
TabStrip9 New
TabStrip10 New
TabStrip11 New
TabStrip12 New
Yahoo TabStrip
Tab Strip - Wizard
Tab Strip - Wizard 2
Add / Remove Tabs
Add / Remove Tabs 2
Time Picker
Features - 30
Fast loading time
Multiple menus - 3
Multiple menus
Multiple menus 2
Horizontal menu and TabStrip
Operations - 9
ShowEvent New
Add / Remove Items New
Hide / Show Items New
Menu item inner HTML New
Attach / Detach
Menu Events
OnClientClick
Menu item postback
Show menu New
Align/Position - 4
Align
Advanced Align
Menu Offsets
Position
Other features - 13
AttachTo
Menu Icons
Menu Customize
Long vertical menus
Long menu items
Disabled menu item
Sub-menus
Custom Menu Items
Using Database
Postback Persistance
Dynamic EasyMenu Item
Full EasyMenu width
Hide menu with time delay
Integration  - 13
TreeView  - 5
Attach to TreeView
Dynamic Loading
Inside callback panel
Select the TreeView node New
TreeView inside EasyMenu
AJAX  - 3
Inside AJAXPage panel
Inside MS AJAX panel
Add items server side
Grid  - 2
Use With Grid
Inside DataGrid column
Inside Window New
Build from SiteMap
Over Java Applet New
Documentation - 3
Server side
Client side
Using the correct path
Knowledge Base - 2
How To and Help
Knowledge Base
What is new