- PlaceHolder Web Server Control
in ASP.NET environment,This article explains you how to work with PlaceHolder Web Control.This control is identical to the Panel control.The PlaceHolder control enables you to place an empty container control in the page and then dynamically add child elements to it at run time.
Grouping set of control with PlaceHolder Control
You can grouping a list of controls and putting them in a PlaceHolder control and then manipulating the PlaceHolder control. For example, you can hide or show a group of controls inside a PlaceHolder by setting the PlaceHolder's Visible property.
- To add a PlaceHolder control to a page
- Type an <asp:PlaceHolder> element in the page.
- then You must want to set the Id and runat properteis of PlaceHolder Web Control
- To add child controls to a PlaceHolder control at run time
- Create an instance of the control you want to add to the PlaceHolder control
- Call the Add of the PlaceHolder control's Controls collection, passing it the instance you created.
the following code snippets demonstrates Add Child Controls to a PlaceHolder Programmatically
-
in .aspx.cs page,
-
void Page_Load(object sender, EventArgs e)
{
TextBox txt1 = new TextBox();
txt1.Text = "txt 1";
PlaceHolder1.Controls.Add(txt1);
}
-
- Related Links
-
96db2c4a-c4a5-46ca-9fd2-a354dcd510e1|0|.0
7139140f-8ac0-4aab-a832-b1d7ae558ac7|0|.0