Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you call master page methods from a content page when the button is inside an update panel?

I have a masterpage and a content page. In the content page I have a script manager and an update panel. In the update panel I want to be able to click a button which would hit a public method on the master page to show a message. This works if I don't have an update panel on the content page but is there a way to get it to work when the button is in an update panel?

Master Page:

public void ShowMessage(string Message) 
{
    lblError.Text = Message; 
    lblError.Visible = True; 
}

Content Page:

Master.ShowMessage("something");
like image 798
Jason Avatar asked Oct 21 '10 16:10

Jason


1 Answers

I think it's a bit late , but for those who are looking for the solution,

Assuming your master page class like:

public MyMAsterPage: MasterPage
{
    public void ShowMessage(string Message) 
    {
       // DO SOMETHING
    }
}

from your content page you can easily call any public method as follow:

(this.Master as MyMasterPage).ShowMessage("Some argument");
like image 133
Amin Avatar answered Sep 24 '22 11:09

Amin