<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" Runat="Server">
<table width="100%" cellpadding="2" cellspacing="0">
<tr valign="top" class="ArticleTitle">
<td style="padding-left:10px;" valign="middle">
asp:PlaceHolder control</td>
</tr>
<tr>
<td class="ArticleContents">
PlaceHolder control is used as a container in which other controls can be added dynamically.
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" Runat="Server">
<div class="ArticleContents">
PlaceHolder control is used as a container in which other controls can be added dynamically.
This control has no HTML output, it is used only to load a control at a specific place on the page (Whereas Panel control has <div> as HTML output.)
<!-- START - Demo Section -->
<table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
<tr>
<td class="DemoTitle">
DEMO : PlaceHolder
</td>
<td align="right">
<a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/controls/placeholder.aspx" target="_blank">Show Source Code</a>
</td>
</tr>
<tr>
<td>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
<pre>
// PlaceHolder Control //////////////////////////////////
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
// Populates the PlaceHolder control //////////////////////////////////
private void PopulatePlaceHolder()
{
// Add ASP.NET Server Control
TextBox txt1 = new TextBox();
txt1.ID = "txt1";
txt1.Width = 300;
txt1.Text = "This control added from Server side.";
PlaceHolder1.Controls.Add(txt1);
// Add HTML controls
string strHTML = "<hr /><table border='1'><tr><td>This contorl and outer HTML Table also added from Server side</td></tr><tr><td><input type='text' name='txtname' id='txtname' /></td></tr></table>";
PlaceHolder1.Controls.Add(new LiteralControl(strHTML));
// Add the usercontrol dynamically
Control webUserControl = (Control)Page.LoadControl("~/tutorials/controls/controldata/WebUserControl.ascx");
PlaceHolder1.Controls.Add(webUserControl);
}
</pre>
</td>
</tr>
</table>
<!-- END - Demo Section -->
</div>
<br />
<script language="javascript" type="text/javascript">
function GiveAlertToUser()
{
alert("Hi Dear, Client side method worked.");
}
</script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" Runat="Server">
</asp:Content>
Go Top