ASP.NET - How to show scroll bars in Panel Horizontal and Vertical

Show scroll bars in Panel Horizontal and Vertical side
Panel is an asp.net web server control that acts as a container control for other controls. panel server control's ScrollBars property get or set the visibility and position of scroll bars in a panel control. panel ScrollBars property have the five possible values those are None, Horizontal, Vertical, Both and Auto.

panel's ScrollBars property value Horizontal only render a horizontal scroll bar in a panel control. ScrollBars property value Vertical only allow us to show a vertical scroll bar on panel server control. if we set the value Horizontal or Vertical for the ScrollBars property value, then the panel will always show the specified scroll bar. it not depend on panel's content size.

the following asp.net c# example code demonstrate us how can we use panel control's ScrollBars property value Horizontal and Vertical in an asp.net application.
PanelScrollBars.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Panel1.ScrollBars = ScrollBars.Horizontal;
        Label1.Text = "Panel now show Horizontal Scroll Bar";
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        Panel1.ScrollBars = ScrollBars.Vertical;
        Label1.Text = "Panel now show Vertical Scroll Bar";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to show scroll bars in Panel Horizontal and Vertical</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">Panel Example: ScrollBars Horizontal/Vertical</h2>
        <asp:Label 
             ID="Label1"
             runat="server"
             Font-Bold="true"
             Font-Italic="true"
             Font-Size="Large"
             ForeColor="Tomato"
             >
        </asp:Label>
        <br /><br />
        <asp:Panel 
             ID="Panel1"
             runat="server"
             Height="150"
             Width="350"
             BorderWidth="3"
             BorderColor="DarkGreen"
             ForeColor="MediumSeaGreen"
             BackColor="AliceBlue"
             Font-Size="Large"
             Font-Names="Comic Sans MS"
             Wrap="false"
             >
             <br />
             This is a test line for panel ScrollBars
             property Horizontal or Vertical.
        </asp:Panel>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="SeaGreen"
             Text="Show Horizontal ScrollBars"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="SeaGreen"
             Text="Show Vertical ScrollBars"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
Related asp.net examples