It is necessary to call content Page function from Master Page. Please let me know if more data needed.
MasterPage.master.cs looks like
protected vo
I usually find that when the MasterPage needs to call a function in a ContentPage you have a flaw in the design of your page. The MasterPage should not need to know anything about the ContentPages. But if you feel that this is the right way for you here is a guide from CodeProject
Personally i did a trick using jquery: When i clicked on the master button, it actually clicked on the content page button named 'saveButton' and used its function:
HTML:
enter code here
.master jquery code:
function tester() {
console.log("Testing");
$("[id$='SaveButton']").click();
}
I used id$='SaveButton' cause as you might know now, ASP.NET renames controls when they are inside a master, a repeater, a grid view, and other containing controls. $id='stuff' validates that the control ID ends with 'stuff'.
you can try like this.. not exactly but will helps you.....
You can inherit your page from a base class. Then you can create a virtual method in your base class which will get overridden in your page. You can then call that virtual method from the master page like this -
(cphPage.Page as PageBase).YourMethod();
Here, cphPage
is the ID of the ContentPlaceHolder
in your master page. PageBase
is the base class containing the YourMethod
method.