ASP. NET 2.0 learning notes -- master page
First of all, because this article is very small, it is mostly nonsense. By the way, if you have time to read the notes of idle people like me and give them a detailed explanation, or even read the computer newspaper, you might as well have time to do what Uncle should do. I am not only hypocritical, but do not like any meaningful or meaningless criticism. Just for fun! No class!
Csdn does not know that it is to strongly prove the robustness of Microsoft's SQL Server. Every night, it always shows us countless times of exception prompts when the connection pool is full. In order to delete the sequentions of F5 after N times of posting the previous article, I deleted the redundant article again in nf5.
The topic and style are mentioned last time, but this time we will mention the master page (which is called the parent page or the home page, which is not very clear, so the original English word is used) is also ASP. NET 2.0 is one of the improvements to web features. I feel that 2.0 has introduced common web features to the server. The master page is designed like a server framework.
Both include and ASP. Net user controls starting with ASP are a solution for the public part of the page. The master page introduced by 2.0 gives a better choice.
In fact, the master page is more like a Dreamweaver template, but it does not actually exist. Unlike Dreamweaver, it only exists during design. The master page defines a framework for a site of the common style, and uses placeholders inside it to represent the parts that can be actually modified. The syntax is as follows.
In the page declaration, the master command replaces the page command, for example, <% @ master language = "C #" %>. The syntax in the master page is not much different from that in a common page, but there is a placeholder control. For example, <asp: contentplaceholder id = "flowertext" runat = "server"/>. The content in the placeholder is its default content. If no new definition is provided for the placeholder in the ASPX page using this master page, it will display its default content. To distinguish it from a common page, the master page ends with a suffix. master.
To use master page on a page, specify the master page path in the masterpagefile attribute in the page declaration. You can define placeholders to display different effects on the page. Syntax ):
<Asp: Content ID = "content1" contentplaceholderid = "flowertext" runat = "server">
With sunshine, water, and careful tending, roses will bloom several times in a season.
</ASP: content>
In fact, if the master page is referenced in the page, only the content corresponding to the placeholder can be defined. What about the titles of different files? In the page command. A title attribute specifies the title of each page.
The master page does not solve the problem of the relative path of the link. Unfortunately, we still have to use the absolute path or application-related path (ASP. NET-specific ~) Solve the Path Problem for references in different paths.
To call and modify the content of the master page in the code, add the following command to the page: <% @ mastertype virtualpath = "site. Master" %>. You can use the master in the code to call the content in the master. There are two methods to call here: Providing properties in a strong type or directly operating the controls in the master page.
The master page can be nested, so you can easily create a general framework for a site and create a more detailed framework for each part.
The syntax for referencing another master page in one master page is the same as that of page. Therefore, it can only contain something like ASP: content.
Refer to [http://book.csdn.net/bookfiles/185/1001858471.shtml]
I have been absent from practice in recent studies, but it's nothing for me (adjectives are omitted about 500 words. If you have any new ideas after practice, write new notes.