How to handle menu post back with master page?

T

tomix

Hi,

I have a master page which contains a menu,i would like to handle post
back
In the content pages(MenuItemClick event)

I tried to do the following in the content page

BaseLayout master = this.Master as BaseLayout;
master.MainMenu.MenuItemClick += new
MenuEventHandler(MainMenu_MenuItemClick); //MainMenu us a property my
master page

But i dont get the events,note that if i am doing the same in the
master page it is ok

Thanks in advance.
 
G

Guest

I suspect you must have switched autoeventwireup to false on the content
page. BTW, you can use <%@ MasterType %> directive on content pages to
instruct compiler to automatically generate strongly-typed Master property.
Regardless your approach should work, you can also intercept menu click using
RaiseBubbleEvent method on master page, and then overriding OnBubbleEvent
method as follows:

master page:

protected void Menu_MenuItemClick(object sender, MenuEventArgs e)
{
RaiseBubbleEvent(sender, e);
}


content page:

protected override bool OnBubbleEvent(object source, EventArgs args)
{
if (args is MenuEventArgs)
{
// take appropriate action
}
else
{
return base.OnBubbleEvent(source, args);
}
}

hope this helps
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top