How to use Panel ScrollBars property Auto and None in asp.net c#

Panel ScrollBars property Auto or None
Panel is an asp.net web server control that act as a container control for other controls and html elements. panel server control's ScrollBars property get or set the visibility and position of scroll bars in a panel control.

the ScrollBars property value type is System.Web.UI.WebControls.ScroolBars. here 'ScrollBars' represents the one of ScrollBars enumeration value. the deafult value of this property is None. ScrollBars enumeration have the following possible values None, Horizontal, Vertical, Both and Auto.

ScrollBars property value 'None' indicate that no scroll bars are shown in panel. this property value 'Auto' means the scroll bars are automatically shown when the size of the panel child contents exceeds the size of the panel control itself. if panel contents exceed only height or width then only verital or horizontal scroll bar will be display in panel control. if contents exceed both height and width of panel control's then the both vertical and horizontal scroll bars will be render in panel server control's.

the following asp.net c# example code demonstrate us how can we use panel ScrollBars property value None and Auto.
PanelScrollBarsAutoNone.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Panel1.ScrollBars = ScrollBars.Auto;
        Label1.Text = "Panel Wrap false and ScrollBars now Auto";
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        Panel1.ScrollBars = ScrollBars.None;
        Label1.Text = "Panel Wrap false and ScrollBars now None";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change Panel ScrollBars property Auto or None</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">Panel Example: ScrollBars Auto/None</h2>
        <asp:Label 
             ID="Label1"
             runat="server"
             Font-Bold="true"
             Font-Italic="true"
             Font-Size="Large"
             ForeColor="Crimson"
             >
        </asp:Label>
        <br /><br />
        <asp:Panel 
             ID="Panel1"
             runat="server"
             Height="150"
             Width="350"
             BorderWidth="3"
             BorderColor="DarkGray"
             ForeColor="Tomato"
             BackColor="LightGoldenrodYellow"
             Font-Size="Large"
             Font-Names="Comic Sans MS"
             Wrap="false"
             >
             <br />
             This is a test line for panel ScrollBars property test.
        </asp:Panel>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="HotPink"
             Text="Panel ScrollBars Auto"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="HotPink"
             Text="Panel ScrollBars None"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
Related asp.net example