---
title: "Panel Control in ASP.NET"  
description: "In this blog, I’m explaining about Panel control in .Net   The panel control is used as a control container. It is useful when you want to group contr"  
author: "priyanka kushwaha"  
published: 2015-02-18  
updated: 2015-02-18  
canonical: https://www.mindstick.com/blog/772/panel-control-in-asp-dot-net  
category: ".net"  
tags: ["c#", "asp.net"]  
reading_time: 2 minutes  

---

# Panel Control in ASP.NET

In this blog, I’m explaining about [Panel control](https://www.mindstick.com/articles/400/panel-control-in-c-sharp-dot-net) in .Net

\
The panel control is used as a control container. It is useful when you want to group [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net) and work then as a single unit. It provides several [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties) that allow you to customize the [behavior](https://www.mindstick.com/forum/159354/runtimeexception-and-exception-behavior) and display of its content. It will render as a div.

##### Properties of Panel control

## Properties Description

BackImageUrl Url of [background image](https://www.mindstick.com/forum/505/how-do-i-have-a-background-image-that-isn-t-tiled) of the panel.

DefaultButton Get & sets the identifier for the default button that is contained in the panel control.

[Direction](https://yourviews.mindstick.com/story/5034/10-animals-with-the-best-sense-of-direction) Text direction in the panel.

GroupText Allows grouping of text as a field.

HorizentalAlign Horizental alignment of the content in the panel.

scrollBars Specifies [visibility](https://www.mindstick.com/blog/301300/how-to-improve-your-visibility-in-zero-click-search-results) and [location](https://www.mindstick.com/blog/11636/relocating-business-or-office-to-another-location) of scrollbars within the panel.

Wrap Allows text wrapping.

##### Example:

##### 1. Create a .asp file

```
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Panelcontrol.aspx.cs" Inherits="AspPanelControl.Panelcontrol" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title></head><body>    <form id="form1" runat="server">    <div>        <div style="float:left">            <asp:Button ID="btn" runat="server" Text="Show" OnClick="btn_Click" /></div>        <div style="float:right">                    <asp:Panel ID="PnlMain" runat="server" GroupingText="Login form" Direction="RightToLeft" HorizontalAlign="Center">            <table>                <tr>                    <td>user Name</td><td>                        <asp:TextBox ID="txtUser" runat="server"></asp:TextBox></td>                </tr>                <tr>                    <td>user Password</td><td>                                               <asp:TextBox ID="txtPass" runat="server" contentPlaceHoler="Enter password"></asp:TextBox></td>                </tr>             </table>         </asp:Panel>              <asp:Panel ID="PnlAd" runat="server" BorderColor="#990000" BorderStyle="Solid" Height="116px" ScrollBars="Both" style="width:278px" DefaultButton="" >                                        <asp:AdRotator                                            ID="AdRotator1"                                            AdvertisementFile="~/XMLFile.xml"                                            runat="server" Target="_top" Width="500px" />                                          </asp:Panel>                                                </div>    </div>    </form></body></html>
```

2. Create a .cs file

```
namespace AspPanelControl{    public partial class Panelcontrol : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            PnlMain.Visible = false;                   }         protected void btn_Click(object sender, EventArgs e)        {            if (btn.Text == "Show")            {                PnlMain.Visible = true;                btn.Text ="hide";                PnlAd.Visible = false;            }            else            {                PnlAd.Visible = true;                btn.Text = "Show";            }                    }    }}
```

3. Create a .[XML file](https://www.mindstick.com/articles/75/how-to-read-and-write-xml-file-through-c-sharp)

```
<?xml version="1.0" encoding="utf-8" ?><Advertisements>  <Ad>    <ImageUrl>~/images/A.jpg</ImageUrl>    <width>40px </width>    <height>50px</height>    <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1228</NavigateUrl>     <AlternateText>DotNetCurry Home Page</AlternateText>    <Impressions>40</Impressions>    <Keyword>small1</Keyword>  </Ad>  <Ad>    <ImageUrl>~/images/B.jpg</ImageUrl>    <width>40px </width>    <height>50px</height>    <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1034</NavigateUrl>    <AlternateText>DotNetCurry Home Page</AlternateText>    <Impressions>40</Impressions>    <Keyword>small2</Keyword>  </Ad>  <Ad>    <ImageUrl>~/images/C.jpg</ImageUrl>    <width>40px</width>    <height>50px</height>    <NavigateUrl>http://www.dotnetcurry.com</NavigateUrl>    <AlternateText>DotNetCurry Home Page</AlternateText>    <Impressions>40</Impressions>    <Keyword>small</Keyword>  </Ad></Advertisements>
```

---

Original Source: https://www.mindstick.com/blog/772/panel-control-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
