How to use a method that is in one of my pages from the masterpage ?
I have a method called Clean ( ) on my page Register, but I want to run it from the masterpage , you can instantiate a class page ?
How to use a method that is in one of my pages from the masterpage ?
I have a method called Clean ( ) on my page Register, but I want to run it from the masterpage , you can instantiate a class page ?
You could try to cast the current page to the type Register
, if that cast succeeds you're there:
var register = this.Page as Register;
if(register != null)
{
register.Clean();
}
However, normally it is nnot od best practice because a master is typically used for multiple pages. So why do you want to hardwire this master to a specific page?
Interacting with the Content Page from the Master Page (C#)
http://www.asp.net/web-forms/overview/older-versions-getting-started/master-pages/interacting-with-the-content-page-from-the-master-page-cs
Interacting with the Master Page from the Content Page (C#)
http://www.asp.net/web-forms/overview/older-versions-getting-started/master-pages/interacting-with-the-master-page-from-the-content-page-cs
How to: Reference ASP.NET Master Page Content
https://msdn.microsoft.com/en-us/library/xxwa0ff0(v=vs.140).aspx
Working with ASP.NET Master Pages Programmatically https://msdn.microsoft.com/en-us/library/c8y19k6h(v=vs.140).aspx