Content Control of ASP. NET Control

Source: Internet
Author: User

Create a server control that contains the text, tags, and other server controls of the contentplaceholder control displayed on the master page.

 
<ASP: Content
Contentplaceholderid= "String"
 
Enableviewstate= "True | false"
ID= "String"
 
Runat= "Server">
Visible = "True | false"
 
<! -- Child controls -->
</ASP: Content>

The content control is the container of the content and control of the Content Page. The content control can only be used with the master page that defines the corresponding contentplaceholder control. The content control is not an independent control.

The followingCodeThe example shows how to use the content control to define the content of the master page. The first webpage is the master page, which uses a contentplaceholder control to define the content area.

  <% @ master language =" C # "%>  
  
     doctype   HTML   Public  "-// W3C // dtd xhtml 1.1 // en " " http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd " > 
    HTML   xmlns   =" http://www.w3.org/1999/xhtml " > 
    head   runat   =" server " > 
    title  > masterpage example    title  > 
    head  > 
    body  > 
    form   id   =" form1 "  runat   =" server " > 
    Div  > 
    Asp: contentplaceholder   id   =" contentplaceholder1 "  runat   =" server " />  
    Div  > 
    form  > 
    body  > 
</Html>

The following code example demonstrates how to use the content page of the master page used in the previous code example. The text, tag, and any server control defined in the Content Control template are displayed to the contentplaceholder on the master page.

<% @ Page Language = "C #" masterpagefile = "~ /Masterpagesample_1cs.master "Title =" content page "%>
 
 
<ASP: Content 
 
Runat= "Server"
Contentplaceholderid= "Contentplaceholder1" >Hello, Master pages!</ASP: Content>

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.