Geeks With Blogs
C# ASP.NET UTILS Programming blogus :-)

To access a method from master page in the content page ensure first:

  •       The method in master page is declared as public

than call this code from your content page code behind:

                     MasterPageClassName MyMasterPage = (MasterPageClassName)Page.Master;

         MyMasterPage.SetMenuToRegistered();

where:

  • SetMenuToRegistered() - is a method positioned in the master page class.

Posted on Monday, December 1, 2008 2:58 AM How to ASP.NET C#? | Back to top


Comments on this post: Call a method from MasterPage in Content Page

# re: Call a method from MasterPage in Content Page
Requesting Gravatar...
Thanks for your remark, I corrected the issue.
Left by Diadiora Alexandru on Jan 12, 2009 10:51 PM

# re: Call a method from MasterPage in Content Page
Requesting Gravatar...
Hi,
I was spent my 2 hours on this but none of scripts work for me your code only worked for me thanks great code.
Left by Shaikh Faraz on Jan 12, 2010 4:59 AM

# re: Call a method from MasterPage in Content Page
Requesting Gravatar...
buddy really outstading code thanks buddy.
Left by Safwan Ahmed on Sep 22, 2010 2:16 AM

# re: Call a method from MasterPage in Content Page
Requesting Gravatar...
That's fine..
but let's consider scenario that,
I have
1. MainMaster.master page
2. ChildMaster.master which inherits MainMaster
3. ContentPage.aspx which inherits ChildMaster

Now I wanna call method defined in MainMaster page in the ContentPage

Is that possible?
and How?
Left by Amol on Apr 19, 2011 11:10 PM

# re: Call a method from MasterPage in Content Page
Requesting Gravatar...
Hey thanks a lot .
it works fine!!!
:)
Left by himasnhu on Nov 15, 2011 12:43 AM

# re: Call a method from MasterPage in Content Page
Requesting Gravatar...
Hey, Super. It work's fine! Greetings.
Left by Vinu on Feb 01, 2013 12:37 AM

Your comment:
 (will show your gravatar)


Copyright © Diadiora Alexandru | Powered by: GeeksWithBlogs.net