Asp.net|erp believes that everyone has used the nested masterpage feature under ASP.net 2.0, which is powerful enough to allow users to create a template page, and then easily apply to other pages. and the stencil page can also be nested, but the nested template page, we will find that there is a problem, that is, when the use of nested template page, in the Design view state, there is no way to visualize the operation, then how to solve this problem? I looked for a foreigner's blog, found a foreigner to provide a method, can be around a corner to solve the problem, the following explanation:
we can write a base class called Basepage.cs, put it in the App_Code directory, and in this class, add a name called
The
Runtimemasterpagefile property is a string type that specifies which template file to use during run time and overrides the Onpreinit
method, the code is as follows:
public class BasePage:System.Web.UI.Page
{
private String Runtimemasterpagefile;
public string Runtimemasterpagefile
{
Get
{
return runtimemasterpagefile;
}
Set
{
Runtimemasterpagefile = value;
}
}
protected override void Onpreinit (EventArgs e)
{
if (runtimemasterpagefile!= null)
{
this. MasterPageFile = Runtimemasterpagefile;
}
base. Onpreinit (e);
}
}
then we construct a template page called Mainmaster.master, which contains a header and footer information, and a
in the middle.
called MainContent's ContentPlaceHolder, and then build a page called Submaster.master, where the
masterpagefile= "~/mainmaster.master" to apply the Mainmaster template page, which places a row and two columns of tables, as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.