Example of Asp.net PlaceHolder Server Control

Example of Asp.net PlaceHolder Server Control:



Asp.net PlaceHolder web Control:

 In the post post we give some theory related to the place holder asp.net control. Now we consider a example here. 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  
<script runat="server">  
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        Image img = new Image();  
        img.ImageUrl = @"~/Images/sea.jpg";  
        img.BorderWidth = 3;  
        img.BorderColor = System.Drawing.Color.SaddleBrown;  
        PlaceHolder1.Controls.Add(img);  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>asp.net PlaceHolder example: how to use</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Navy">PlaceHolder Example</h2>  
        <asp:PlaceHolder   
            ID="PlaceHolder1"  
            runat="server"  
            >  
        </asp:PlaceHolder>  
        <br />  
        <asp:Button   
             ID="Button1"   
             runat="server"   
             Text="Add Image Control"   
             OnClick="Button1_Click"   
             Font-Bold="true"  
             ForeColor="SaddleBrown"  
             />  
    </div>  
    </form>  
</body>  
</html>  


Asp.net Related Other Post:

Comments

Popular posts from this blog