WebForm Master Page

Source: Internet
Author: User

Master page:
You can reuse some of the code in the interface

Add New Item-master page

In the master page, the interface code is not written in

<asp:contentplaceholder id= "Head" runat= "Server" >
</asp:ContentPlaceHolder>

And

<asp:contentplaceholder id= "ContentPlaceHolder1" runat= "Server" >
</asp:ContentPlaceHolder> in

When you add a Web form, you add it from the Add new item, tick the master page before selecting it, and select the master page to apply the master page

Replace the holes left in the master page by filling in the interface code in the appropriate ContentPlaceHolder in the Web form that applies the master page

Master Page Nesting

Continue to add new item-master page, tick before selecting Master page, select a master page to apply master page

In <asp:contentplaceholder id= "ContentPlaceHolder1" runat= "Server" >
The </asp:ContentPlaceHolder> writes the interface code as the master.

After writing to the user to leave a hole for their own layout, dragged into a ContentPlaceHolder control to pay attention to change the ID, otherwise it will be the same name.

The delivery of data between a master page and a child page:

A control that is not called directly on a sub-page in a master page, the workaround

In the master page background code to write a method, this method requires parameters can be passed as data, by the sub-page to adjust the master page in the method of data transfer.

MP2 m2 =this.    Master as MP2;   Instantiate the master page. The MP2 master page is also a class m2= the master page of the current page is converted to MP2;

Then call the method in M2 to pass the arguments past.

If you are passing from a child page to a primary master page, you need to pass it through a level two master.

Methods in a Level two master page

Methods in a primary master page

Master Page The common external style sheet path matches the path of the external JS file:

The external style sheet is introduced to the master page, and the corresponding path is automatically matched, regardless of the control.

If the external JS file introduced will not automatically match, the JS file dragged into, the src= "path" transposition of a Method <%=abc ()%> out a C # variable. Be careful to write <script></script> as much as possible in the form form.

Background method

Take the original path with Resolveclienturl () This method to get the correct path of auto-match

WebForm Master Page

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.