ASP.NET Basic controls

Discussion in 'ASP.NET' started by MinalS, Jul 22, 2015.

  1. Web server controls are created on the server. The runat="server" attribute is added to the control. The control is processed by the server. Some of the basic web server controls are mentioned below.
    1. Label control
    2. TextBox control
    3. ListBox control
    4. CheckBox and CheckBoxList control
    5. RadioButton and RadioButtonList control
    6. DropdownList control
    7. Button control
    8. ImageButton control
    9. Wizard control

    1. Label control

    The label control is used to show the text in a form. The text cannot be modified by user. The text is static.

    The properties for the label control are:
    1. Text: The text for the label is assigned or retrieved
    2. Visible: The label control is visible to the user
    Syntax for label control:
    <asp:Label ID="label1" runat="server" Text="Name" />

    2. TextBox control

    The data is retrieved from the user through the textbox control. The textbox control is single line, multi line or password. In single line textbox, characters are added to single line. For multi line, multiple lines are displayed. The characters are masked in the password.

    The properties for the textbox control are:
    1. Text: The text in the textbox control is accessed or assigned
    2. Rows: The vertical size of the textbox control is assigned
    3. Height: The height of the control is assigned
    4. MaxLength: The maximum number of character is entered in the control.
    Syntax for textbox control:
    <asp:TextBox ID="Text1" runat="server" ></asp:TextBox>

    3. ListBox control

    The collection of list items is defined in the listbox control. More than one item can be selected using the control.
    1. Rows: The vertical size of the listbox control is set. If there are more times, a scroll bar is added to it.
    2. Items: The collection of list items is represented in the control
    3. SelectionMode: The number of items selected by the user is set. The property can have value as Single or Multiple.
    4. SelectedValue: The value of the item currently selected by the user. The value is dependent on one or more items selected.

    4. CheckBox and CheckBoxList control

    The individual choices are provided to the user through the checkbox control. A single checkbox is added to the web form. The checkboxlist contains collection of checkboxes. The list is useful when the user needs to add a series of checkboxes to the page.

    Syntax for CheckBox control:

    <asp:CheckBox ID="CheckBox1" runat="server"></asp:CheckBox>
    Syntax for CheckboxList control:

    <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged" >
    Properties of the checkbox control are:
    1. Text: The text for the checkbox control is added.
    2. Items: The individual check boxes are added to the control.
    3. TextAlign: The alignment of the Text property of the control
    4. RepeatDirection: The direction to which the control must be repeated is defined
    5. RepeatColumns: The number of columns used for repeating the values

    5. RadioButton and RadioButtonList control

    The radiobutton control provides set of choices. The control can be added to the web form. A single radio button is added in the radiobutton control. A collection of radio buttons is added to the radiobuttonlist.

    Syntax for RadioButton control:
    <asp:RadioButton ID="Radio1" runat="server" ></asp:RadioButton>
    Syntax for RadioButtonList control:
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButton1_SelectedIndexChanged" >
    Properties of RadioButtonList control:
    1. Text: The text for the radiobutton control is added.
    2. TextAlign: The alignment of the Text property of the control
    3. Items: The individual radio buttons are added to the control.
    4. RepeatColumns: The number of columns used for repeating the values

    6. DropdownList control

    The control allows user to select the values from some predefined items. An item is a separate object containing the properties. User can add items through the Items property. Only one item can be selected at a time.

    Syntax for dropdown list control is:
    <asp:DropDownList ID="Drop1" runat="server">
    The properties used in the drop down list control are:
    1. Items: The collection of items present in the drop down list
    2. Width: The width of the control is set.
    3. Height: The vertical size of the control is set

    7. Button control

    The control is used for posting the data from the user to the web applications. The page is posted to the server, the click event is triggered. Three types of button as LinkButton, ImageButton and Button are provided by ASP.NET.
    1. ImageButton: It is added in the form of a graphic button. A good look of the button appears to the user.
    2. LinkButton: It is used as a hyperlink on the web page. The client side script is used for performing the postback to the server.
    3. Button: The general button used for rendering the HTML input element.

    8. ImageButton control

    An imagebutton is used for displaying an image. All the image control properties are inherited using the ImageButton control.

    Properties of ImageButton control:
    1. ImageAlign: User for aligning the image on the page. The values can be top, left, right, bottom, etc.
    2. ImageURL: The URL of the image is shown
    3. CommandName: The command name associated with the control is displayed.
    4. AlternativeText: The text to be displayed when the web browser does not support the images.
    5. CommandArgument: The event associated with the command name.

    9. Wizard Control

    The wizard contains group of forms for performing the specific task. It performs step by step task for collecting user related information. It provides user with built in steps, add new steps and modify the order of the steps.

    User can navigate between the steps provided by the wizard. The data across the pages is maintained in the state while performing the wizard steps.

    Properties of the wizard control are:
    1. ID: It states the unique identifier associated with the control
    2. Enabled: The value stating the wizard content is enabled.
    3. ToolTip: The text to be shown when the mouse hovers over the control
    4. WizardSteps: A collection of all the WizardStepBase objects used for defining the control

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice