I have multiple master pages in my application. I made a custom type and inharit all master pages from it:
public class MyMaster : System.Web.UI.MasterPage
{
private int myno;
public int MyNo
{
get { return 50; }
set { myno = value; }
}
}
Basically myno is common in all master pages and master pages will be changing in content pages. To add this property I added in my content page:
<%@ MasterType TypeName=MyMaster %>
Running on page I got subject error. Kindly guide me.
Thank
If you’re working in a web site, you should typically put a derived MasterPage class in the application’s App_Code folder. When VS compiles your site, classes in the AppCode folder are compiled into the site’s namespace and available to the code-behind pages of the application.
If you’re using a web application, you should be able to put the class file in the root of the site and reference it directly from the code-behind of any other page in the project, assuming all namespace references are correct.
Also make sure that your the
Build Actionfor your class file is set toCompile. You can check this in the properties window by selecting the class file in solution explorer.