Asp.net master ticket

Source: Internet
Author: User

What is the master region?

When you need to reuse the content, you can use the primary volume. A primary volume defines a public content in the primary volume just like a template.(That is, cannot change the content)And can change the content.
The development name of the primary region is. Master.
The source region of the master region is as follows:

<% @ Master language = " C # " Autoeventwireup = " True " Codefile = " Eventregistratrion. master. CS " Inherits = " Eventregistratrion "   %>

<!Doctype HTML public"-// W3C // dtd xhtml 1.0 transitional // en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< HTML xmlns = " Http://www.w3.org/1999/xhtml "   >
< Head runat = " Server " >
< Title > Untitled faces </ Title >
</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< Div >
< ASP: contentplaceholder ID = " Contentplaceholder1 " Runat = " Server " >
</ ASP: contentplaceholder >
</ Div >
</ Form >
</ Body >
</ Html >


Method for adding a primary shard:
Add a new category to the solution and select "main version. You can use tables, contentplaceholder controls, and other design surfaces in the added primary keys.

Use the primary volume method:
Method 1: use master nodes for a single region
When a primary plane is used, you must add masterpagefile = "~ /Eventregistratrion. Master "adequacy. The following generation:

<% @ Page Language = " C # " Masterpagefile = " ~ /Eventregistratrion. Master " Autoeventwireup = " True "
Codefile = " Default2.aspx. CS " Inherits = " Default2 " Title = " Untitled page "   %>

Method 2: Use primary keys on all hosts
When you need to use all hosts as the primary plane, you need to add the following generation in Web. config to distribute the primary plane to all hosts.

< System. Web >
< Pages masterpagefile = " ~ /Eventregistratrion. Master " > </ Pages >
</ System. Web >

Note: 1. When a primary region is set in a certain area, the primary region defined in Web. config will not work.
2After the definition subject is added to the project, check the main version of the project. In this way, the new plane becomes the master plane.

Method 3: select a primary node for the root node.

In this example, there are multiple primary nodes. In this case, the root node needs to switch between the primary nodes to determine the primary node. The page_preinit event is required. The token generation is as follows:

This . Preinit + =   New Eventhandler (_ default_preinit );

Void _ Default_preinit ( Object Sender, eventargs E)
{
If (Request. useragent. Contains ( " MSIE " ))
{
// Select a primary node
This . Masterpagefile =   " ~ /Eventregistratrion. Master " ;
}
Else
{
// Select another primary node
This . Masterpagefile =   " ~ /Default. Master " ;
}
}

The primary layout applies to the primary layout:
The plane of the master version of the quilt cover needs to be changed. The generation plane is as follows: <% -- Set the master region -->
<% @ Page Language = " C # " Masterpagefile = " ~ /Main. Master " Autoeventwireup = " True "
Codebehind = " Default. aspx. CS "
Inherits = " Webscottforum. Default "   %>

<% @ Mastertype virtualpath = " ~ /Main. Master "   %>
<% -- Zookeeper Content in contentplaceholder, Contentplaceholderid: corresponds to the ID of contentplaceholder on the primary plane. -->
< ASP: Content ID = " Content1 " Runat = " Server " Contentplaceholderid = " Contentplaceholdermain " >
< HR Align = " Center " Color = " Red " Size = " % 100 "   />
Content to be displayed < BR />
< BR />
< BR />
Ha ha < BR />
< BR />
< BR />
</ ASP: Content >
<% -- Disable this part
<! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en "
" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< HTML xmlns = " Http://www.w3.org/1999/xhtml " >
< Head runat = " Server " >
< Title > Untitled faces </ Title >
</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< Div >
</ Div >
</ Form >
</ Body >
</ Html > -- %>

Alternatively, when you create An ASPX instance, check "select the primary version 」

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.