You can do that in a few ways.
Set delegate on Master Page.
public partial class Site : System.Web.UI.MasterPage
{
public Action SomeAction;
}
public partial class Page : System.Web.UI.Page
{
protected void btn_Click(object sender, EventArgs e)
{
((Site)Master).SomeAction= PageAction;
}
public void PageAction(){
}
}
Create your custom event:
public delegate void SomeEventHandler
(object source, SomeEventArgs args);
public class SomeEventArgs
{
public object Data { get; set; }
}
public partial class Site : System.Web.UI.MasterPage
{
public event SomeEventHandler SomeEvent;
}
public partial class Page : System.Web.UI.Page
{
protected void btn_Click(object sender, EventArgs e)
{
((Site)Master).SomeEvent= PageHandler;
}
public void PageHandler(object source, SomeEventArgs args){
args.Data = 1;
}
}
It's usefull for sharing some simple data between page and master.
But I would only recomend this if you hurry.
It's not cleanest way to do it IMHO.
I would prefer to create some context data class. Register it in IoC container with life span HttpSession. Dependency Injection would take care of setting
correct instance of this context in your Page and MasterPage and you could share some data between them using your context as intermediate object.
But it is more complex but solution and I don't know if you even using container in your project.