Search
Author
ASP.NET Tutorials
Author
Sheo Narayan
Advertisements


Winners

Win Prizes

Social Presence
Like us on Facebook

Silverlight Tutorials | Report a Bug in the Tutorial
asp:Panel control
Panel control is generally used to keep a set of controls into it.
 
Panel control is generally used to keep a set of controls into it. It is frequently used when you have to programmatically generate controls. When it is rendered on the page, generally it is implemented through <div> HTML tag.

Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <input> tag.

Following are some important properties that are very useful.
GroupingText Its used to set the caption of the group of controls inside the panel.
Visible true/false. Used to hide or show the panel.
DEMO : Panel Show Source Code
Panel Control Test
This contorl and outer HTML Table also added from Server side
 
// Panel Control /////////////////////////////////////////////
<asp:Panel ID="Panel1" runat="server" GroupingText="Panel Control Test"></asp:Panel>

// Code Behid Code /////////////////////////////////////////////
 private void PopulatePanel()
    {
        // Add ASP.NET Server Control
        TextBox txt1 = new TextBox();
        txt1.ID = "txt1";
        txt1.Width = 300;
        txt1.Text = "This control added from Server side.";
        Panel1.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>";
        Panel1.Controls.Add(new LiteralControl(strHTML));
            
    }