PlaceHolder control example
Previous | Home | Next |
The PlaceHolder control is used to reserve space for controls added by code.The PlaceHolder control does not produce any visible output (it only acts as a container for other controls on the Web page).
property:- runat:-runat Specifies that the control is a server control. Must be set to "server"
.....................Designing code for PlaceHolder control........ ................................................................... <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>.................................................................................................cs code................................ ................................................................... using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = "Created text box1"; TextBox2.Text = "Created text box2"; TextBox1.Columns = 15; TextBox1.ReadOnly = true; TextBox2.Columns = 20; Button1.Text = "Submit"; PlaceHolder1.Controls.Add(TextBox1); PlaceHolder1.Controls.Add(TextBox2); PlaceHolder1.Controls.Add(Button1); } } ...................................................................Untitled Page
Previous | Home | Next |