-->

22 December 2019

Asp.Net Panel Control

  Asp.Net CS By Example       22 December 2019


  The Panel Control :
 In this post,we are leaning about ASP.NET Panel Control.The Panel control is used to work with a group of ASP.Net controls.For example, We can use a Panel control to hide or show a group of ASP.NET controls.
Syntax:
<asp:Panel ID="pnlContact" runat="server" />

The Panel control supports the following properties (this is not a complete list):
S.N. Property Description
1) ID Set the uniqe value to control to access in code-behind code.
2) DefaultButton Used to set the default button in a Panel. The default
button is invoked when we press the Enter button.
3) Direction Used to get or set the direction in which controls that display
text are rendered. Possible values are NotSet, LeftToRight, and RightToLeft.
4) BackColor change the background color of the panel control.
5) BorderColor set the color of a border rendered around the panel control.
6) BorderStyle display a border around the panel control. Possible values are NotSet, None, Dotted, Dashed,
Solid, Double, Groove, Ridge, Inset, and Outset.
7) BorderWidth set the size of a border rendered around the panel control.
8) CssClass Associate a Cascading Style Sheet class with the panel.
9) Font Set the label’s font properties.
10) ForeColor Set the color of the content rendered by the panel.
11) Style Assign style attributes to the panel.
12) ToolTip Set a panel’s title attribute.
13) GroupingText Used to display the Panel control as a fieldset with a particular legend.
14) HorizontalAlign Used to specify the horizontal alignment of the contents
of the Panel. Possible values are Center, Justify, Left, NotSet, and Right.
15) ScrollBars Used to display scrollbars around the panel’s contents. Possible
values are Auto, Both, Horizontal, None, and Vertical.
16) Visible Used to display or hide the panel control.
17) Width Used to set the width of panel control.
18) Height Used to set the height of panel control

  By default, a Panel control display a <div> tag around its contents. If we set the
GroupingText property, however, the Panel control renders a <fieldset> tag. The
value that we assign to the GroupingText property appears in the <fieldset> tag’s <legend> tag.
  The ScrollBars property used to display scrollbars around a panel’s contents.
The panel is configured to scroll when its contents overflow its width or height.
  When enabling scrollbars with the Panel control, we must specify a particular width and
height to display the scrollbars.

Code: PanelExm01.aspx

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PanelExm01.aspx.cs" 
    Inherits="LearnAsp.Net.ControlDemo.Panel.PanelExm01" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Panel
                ID="pnlContact"
                GroupingText="[ Contact Information ]"  DefaultButton="btnSubmit"  BackColor="#ababab" 
                BorderStyle= "Ridge" BorderWidth="10" Direction="NotSet" Font-Bold="true" 
                ForeColor="#AD09AF" ScrollBars="Auto" ToolTip="Panal" ViewStateMode="Disabled" Width="400 px" 
                Height="100px" SkinID="1"  Visible="true" runat="server">
                <asp:Label
                    ID="lblFirstName"
                    Text="First Name:"
                    AssociatedControlID="txtFirstName"
                    runat="server" />
                <br />
                <asp:TextBox
                    ID="txtFirstName"
                    AutoCompleteType="FirstName"
                    runat="server" />
                <br />
                <br />
                <asp:Label
                    ID="lblLastname"
                    Text="Last Name:"
                    AssociatedControlID="txtLastName"
                    runat="server" />
                <br />
                <asp:TextBox
                    ID="txtLastName"
                    AutoCompleteType="LastName"
                    runat="server" />
                <br />
                <br />
                <asp:Button ID="btnSubmit" Text="Submit" runat="server" />
            </asp:Panel>
        </div>
    </form>
</body>
</html>

Output:

logoblog

Thanks for reading Asp.Net Panel Control

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.