I have a public method in my content page class, I want to call this method from master page class.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 –
Here,
cphPageis the ID of theContentPlaceHolderin your master page.PageBaseis the base class containing theYourMethodmethod.EDIT: Of course, you’ll have to put a null checking before you call the
YourMethodmethod using the page’s instance.