Search Engine

Thursday, May 20, 2010

ASP.Net Panel Control

The ASP.Net Panel control is a web server control that is rendered as div element of HTML. The div tag of HTML stands for logical division block that can hold the other controls. It serves as a container for other web server or HTML controls to provide the managed layout to the web page. The Panel control is a server control that renders on web page using the basic HTML markup code of div element. It has different types of properties that can be used to customize its appearance on web page. These properties render as attributes of div tag that renders the panel control.

Following are the properties of ASP.Net Panel Control:

BackColor: It allows you to set the background color of the panel control.

BackImageUrl: It sets the background image of the control.

BorderColor: It sets the color of the border around the panel control.

BorderStyle: You can set the style of border using this property. It supports the following predefined types of border styles:

  • Dashed
  • Dotted
  • Double
  • Groove
  • Inset
  • None
  • NotSet - It is the default value of BorderStyle property that does not render the border around the panel control.
  • Outset
  • Ridge
  • Solid

BorderWidth: It allows you to set the width of the border using CSS units such as px, pt, cm etc.

CssClass: You can specify the CSS class name for this property to apply the CSS styles to Panel control.

DefaultButton: It accepts the ID of the Button control that you want to set as default button. The default button works as the submit button for a specific group of controls whether the controls are placed inside the Panel control or web form. Specifying the ID of the Button control to the DefaultButton property of Panel control executes the associated server side event of that button when user hits the enter key from the keyboard.

Direction: It accepts one of the predefined keyword values that sets the direction of the text placed inside the Panel control. It supports the following predefined values:

  • NotSet - default value.
  • LeftToRight
  • RightToLeft

Font-properties: The font property group contains following set of properties which allow you to change appearance of text placed inside the Panel.

  • Font-Bold
  • Font-Italics
  • Font-Names
  • Font-Overline
  • Font-Size
  • Font-Strikeout
  • Font-Underline

ForeColor: It allows you to set the font color of the text.

GroupingText: It renders the group box with a text at top left corner inside the Panel control. The group box is being rendered by fieldset and legend HTML elements that display the bordered group box with a caption text.

HorizontalAlign: It sets the horizontal alignment of the text placed inside the Panel control.

Height: It sets height of the control.

Scrollbars: It enables you to display the scrollbars for the Panel control. You can control the appearance of scrollbars by specifying one of the predefined values for this property:

  • None
  • Horizontal
  • Vertical
  • Both
  • Auto

This property sets the CSS overflow property value for the div tag that generates the panel control on the web page.

Width: It sets the width of the control.

Wrap: It allows to enable or disable the text wrapping.

You can also customize the look of ASP.Net Panel control using inline style attribute by specifying the CSS properties in the HTML markup code block.

Sample Code for ASP.Net Panel Control

asp:Panel ID="Panel1"
Style="border: solid 1px #c0c0c0; width: 300px;
height: 300px; float: left"

Continue to the next tutorial: ASP.Net PlaceHolder control that provides the functionality to render as invisible container on the web page just as a server side place holder which allows you to add the ASP.Net controls dynamically.


Post a Comment