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.
EDIT: Of course, you'll have to put a null checking before you call the YourMethod
method using the page's instance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…