Getting Master Page Events From Child Pages

G

gencode

I have a logout link in a master page...when the link is pressed I want
to capture that event in the child page, not the master page, becase
there is some processing I want to do in the child page...is there an
easy way to capture the "Handles LinkButtonLogout.Click" from the
child page?

Thanks, Ed,
 
G

Guest

First, you’ll need to write a public method (property) in a master page:

public partial class MyMasterPage : System.Web.UI.MasterPage
{
public Button GetMyButton() { return Button1; }
}

Second, you’ll need to assign an event handler manually in a child page:

public partial class ChildPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
(Master as MyMasterPage).GetMyButton().Click += new
EventHandler(ChildPage_Click);
}
}

Alexey Borzenkov
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top