What is PlaceHolder?

Source: Internet
Author: User

What is PlaceHolder?

PlaceHolder is a PlaceHolder control. You can add a child control to it.

1. What are ContentPlaceHolder and Content?

These two are used for master technology.

ContentPlaceHolder is used on the master page, indicating that the Content can be replaced by the Content on the aspx page. Of course, the Content on the aspx page can be ignored.

Content is used for the aspx page. The Content has a ContentPlaceHolderID attribute, which indicates that the ContentPlaceHolder in the master will put the Content in the Content.

2. What are content placeholder controls, content controls, and content areas?

The content placeholder control represents the replaceable content area on the master page. They are displayed as <asp: ContentPlaceHolder> in the "code" view, and are mapped to their content placeholder controls by the contentplaceholderid attribute. The content placeholder defines the default content of the region specified by the content placeholder control. The default content specified by the content placeholder can be modified on the master page to make this change appear on all webpages attached to the master page.

In addition, the Content control (displayed as <asp: Content> in the "code" View) can also be used on a single Content webpage to overwrite the default Content of the Content placeholder provided by the master page.

The content area is the master page area defined by a single content placeholder. In the Code view, the content area is surrounded by the content placeholder control mark (if the content is provided by the master page) or content control flag (if the content belongs to the custom content in a single content webpage ).

Note that the content in the content placeholder provided by the master page does not appear in the content placeholder on the content webpage.

3. What are PlaceHolder users? 1. PlaceHolder control PlaceHolder usage-Batch Management Control

In ASP. NET, The PlaceHolder control PlaceHolder does not output any HTML tag to the client. PlaceHolder can be used to group controls to facilitate batch management.

<asp:PlaceHolder ID="PlaceHolder1" runat="server">      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>      <asp:TextBox ID="TextBox2" runat="server">  </asp:TextBox></asp:PlaceHolder>


Place the preceding two TextBox strings in PlaceHolder, and use PlaceHolder1.Visible = false. You can hide both TextBox strings at the same time (not output to the client ). Instead of setting Visible one by one.


2. PlaceHolder control PlaceHolder usage-dynamically add controls

In ASP. NET, The PlaceHolder control PlaceHolder does not output any HTML tag to the client. PlaceHolder can be used to "Occupy the location" and then dynamically process the control in the Program (usually dynamic addition ).

<Asp: PlaceHolder ID = "PlaceHolder1" runat = "server"> </asp: PlaceHolder>

Create another control and add it to PlaceHolder.

System. Web. UI. WebControls. TextBox tb = new TextBox (); tb. ID = "TextBox1"; tb. Text = "Text box"; PlaceHolder1.Controls. Add (tb );

Conclusion: The PlaceHolder control is used as a container to store the control dynamically added to the web server. The PlaceHolder control does not produce any visible output, but serves as another control of the container on the web page.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.