Asp.net summary master

Source: Internet
Author: User

1. When a master is used, the content control must one-to-one match with the contentplaceholder control on the master page.

2. If the contentplaceholder control of the master page has the default content and the content page does not have the content control, the content of the master page is displayed. Otherwise, the default content on the master page is not displayed even if the content control is empty.

3. If the content page needs to interact with a control on the master page (similar to other interactions), follow these steps:

1) In the master page classCodeCreate a public attribute. Its get and set correspond to the value of the control. (If the master page has a control ID of masterlbl)

 
Public StringMasterlbl {Get{ReturnMasterlbl. Text ;}Set{Masterlbl. Text =Value ;}}

2) You can call the following in the content page class:

(Mymaster) Master). masterlbl ="Test";

Here, the master is an object of the master class. You need to convert it to the corresponding master Type for interaction! Of course there are other methods, but this method is the most convenient. In this way, you can modify the masterlbl value of the Master Control.

4. The master and master can be nested. When nesting, the Child-master page must have the same content control as the content page and the parent page. When using the content page of the Child master page, you do not need to have the content control to correspond to the previous master page, as long as it corresponds to the contentplaceholder control of its own master page. If the child version has the contentplaceholder control, it must be placed in the content control corresponding to the parent version, as shown below:

 <  ASP: Content  ID  = "Content2"  Contentplaceholderid  = "Contentplaceholder1"  Runat  = "Server" >      <  ASP: contentplaceholder  Runat  = "Server"  ID  = "Contentplaceholder2"  > </  ASP: contentplaceholder  >  </  ASP: Content  > 

The content page mainly corresponds to contentplaceholder2!

5. Relative Path of the master page

Assume that the master page contains an image

<IMGSRC= "T.jpg" />

If the master and image are in the same level of directory and the content page are different from the image, the image cannot be displayed because the image address is replaced by the content page with the address of the relative content page.
Solution:

1) use the full path <% = resolveurl ("~ /Scripts/jquery-1.4.1.min.js ") %> (BEST)

2) use server controls instead (JS and CSS non-controls cannot be solved)

 

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.