Onlineatoz.net | ToolBox Standard Control PlaceHolder

ToolBox Standard Control PlaceHolder

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

Posted by: Admin
Posted on: 9/13/2011 at 1:52 PM
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed