Export (0) Print
Expand All

Panel.ScrollBars Property

Gets or sets the visibility and position of scroll bars in a Panel control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract ScrollBars : ScrollBars with get, set 
override ScrollBars : ScrollBars with get, set
<asp:Panel ScrollBars="ScrollBars" />

Property Value

Type: System.Web.UI.WebControls.ScrollBars
One of the ScrollBars enumeration values. The default is None.

Use the ScrollBars property to specify the visibility and position of scroll bars in a Panel control. This property is set using one of the ScrollBars enumeration values. The following table lists the possible values.

Value

Description

None

No scroll bars are shown.

Horizontal

Only a horizontal scroll bar is shown.

Vertical

Only a vertical scroll bar is shown.

Both

Both horizontal and vertical scroll bars are shown.

Auto

If necessary, horizontal, vertical, or both scroll bars are shown. Otherwise, no scroll bars are shown.

If you specify Auto for the ScrollBars property, scroll bars are automatically shown when the size of the content in a Panel control exceeds the size of the Panel control itself. For example, if a Panel control contains a table, and the panel is not wide enough to display all the rows in the table, a vertical scroll bar is shown. If the size of the table exceeds the height and width of the panel, both vertical and horizontal scroll bars are shown.

NoteNote

This property is supported only on browsers that support HTML 4.0 or later.

TopicLocation
How to: Add Panel Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add Panel Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications

The following code example demonstrates how to declaratively set the ScrollBars property to Auto. The panel contains a table, the entire contents of which exceed the size of the panel. This causes both vertical and horizontal scroll bars to be automatically displayed when the panel is rendered. The user can then scroll to view all the data in the table.

NoteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to programmatically set the ScrollBars property. A ListBox control is populated with the ScrollBars enumeration values. The scroll bars displayed in the panel change, based on the value the user selects from the list box.

NoteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft