Home | HTML | Asp.Net | HTML Probe | .Net Probe
   
 www.solvingera.com 
  Contact Us |Sitemap
  
 

Web Server General Controls

Skip Navigation LinksHome>Asp Home>General Controls

Web server controls are powerful because they are not explicitly tied to specific HTML elements; rather, they are more closely aligned to the specific functionality that you want to generate.closely aligned to the specific functionality that you want to generate.

There are many General Controls in Visual Studio under ASP.NET Section. Some of Important General Controls are given below:-

The Label Server Control

The Label server control is used to display static text in a web form that cannot be edited by the user. The text property of the lable control can be set to modify the control’s caution.

Some properties of Lable control are:-
  • Text: Sets the text of the label control.

  • Visible: Display or hides the label control.
Control ExampleOutput
Label Control <asp:Label ID="Label2" runat="server" BackColor="#3FBE3F" Font-Italic="True" ForeColor="#97003D" Height="20px" Text="Label Control" ToolTip="Solvingera Label" Width="110px"></asp:Label> Label Control

The Literal Server Control

The Literal server control works very much like the Label server control does. This control was always used in the past for text that you wanted to push out to the browser, but keep unchanged in the process. Generally this control is used to display error message or a custom message.

Control Example Output
Literal Control <asp:Literal ID="Literal2" runat="server" Text="Display Error Message"></asp:Literal>Display Error Message

The TextBox Server Control

The textbox control is used to obtain information, such as text, number and dates from users in a web form. You can set a textbox control as Single line, Multiline or Password TextBox control. By default a textbox is single line that allow user to type character in a single line.

Some properties of textbox control are :
  • Text: Sets the text in a textbox control.

  • Height: Sets the height of the textbox control.

  • Rows:  Allows you to set the vertical size in the number of rows. If you sets the height and row property for the textbox control, then Height property takes precedence.

  • Wrap:  Allows you to set the word wrap behavior in a multiline Textbox control.
Control ExampleOutput
Simple TextBox <asp:TextBox ID="TextBox4" runat="server" ForeColor="#00356A" Height="18px"></asp:TextBox>
Password TextBox <asp:TextBox ID="TextBox4" runat="server" Height="18px" TextMode="Password"></asp:TextBox>
Multiline TextBox <asp:TextBox ID="TextBox4" runat="server" TextMode="MultiLine"></asp:TextBox>

Note:

Focus() Method

The Focus() method enables you to placed the cursor inside the textbox control automatically when you load a webpage.
Code should be written on Page_Load event.
TextBoxName.Focus();


The Button Server Control

The Button control generally used to submit a form or data that is entered by a user as an input on a webpage. When the user clicks a button control, the page is posted back to the web server and click event is triggered.

There are three types of button control provided by ASP.NET.
  • Button: It is a standard common button that is rendered as an HTML input element.

  • LinkButton:- It a hyperlink button on a webpage. It contains client-side script that causes the form to be posted back to the server.

  • ImageButton:- ImageButton is in the form of a graphic button. It is used for presenting a rich button appearance.

    Some properties of the ImageButton control are:

    • AlternativeText: Sets the alternative text that is displayed when a web browser does not support image.

    • CommandArgument: Passes a value to the command even along with the associated command name when the button is clicked.

    • ImageAlign: Sets the alignment of the image.

    • ImageURL: Specify the URL of the image to be displayed.

    • CauseValidation: Specifies whether validation will be performed when the button is clicked. If the value is false, the form submitted by the button is not validated.
Some common properties of all three common buttons are:
  • ID: Sets the unique identifier assign to the button control.

  • Text: Sets the text that is displayed on the button control.

  • PostBackURL: Sets the URL of the page to which the data is posted.

  • Enabled: Sets a value indicating whether the button control is enabled or not.

  • ToolTip: Sets the text displayed when the mouse pointer hover over the button control.
Control Example Output
Button Control <asp:Button ID="Button2" runat="server" Text="Solvingera Button" Height="30px" Width="120px" BorderColor="#C7D17C" />

The HyperLink Server Control

Hyperlinks are links that allow end users to transfer from one page to another. Hyperlink is the easiest way to travel between webpages. You can set the text property of a hyperlink using the control’s Text attribute.

Some common properties of Hyperlink control are:
  • Text: Sets the text which is displayed on a web browser as a hyperlink.

  • ImageUrl: ImageUrl creates a graphical link.

  • NavigateUrl: Specify the destination URL to which you want to go after clicking the hyperlink.

  • Target: Indicates the ID of a target window or frame in which you want to display as a link page.
Control Example Output
Hyperlink Control <asp:HyperLink ID="HyperLink1" runat="server" Font-Bold="True" Font-Italic="False" Font-Underline="True" NavigateUrl="~/html/intro.aspx">Click for HTML</asp:HyperLink> Click for HTML

The DropDownList Server Control

DropDownList control allows user to select an item from a large collection of predefine items. Depending on the number of choices available in the select box, the end user may have to scroll through a list of items.

Some properties of DropDownList Control are:
  • Items: Represent the list of items in the DropDownList control.

  • Width: Sets the width of the control.

  • Heigth: Sets the height of the control.

The ListBox Server Control

The ListBox control is a collection of list items. It allows user to select one or more items from the list.

Some properties of listbox control are:
  • Items: Represent the list of items in the ListBox control.

  • Rows: Sets the vertical size of the listbox control and takes a value in number of rows.

  • SelectionMode: Sets the number of items that can be selected. To allow user to select only one item, SelectionMode property should be single else Multiple.
Control ExampleOutput
DropDownList Control <asp:DropDownList ID="DropDownList2" runat="server">
<
asp:ListItem>Select Country</asp:ListItem>
<
asp:ListItem>India</asp:ListItem>
<
asp:ListItem>United States</asp:ListItem>
<
asp:ListItem>United Kingdom</asp:ListItem>
<
asp:ListItem>Japan</asp:ListItem>
<
asp:ListItem>China</asp:ListItem>
<
asp:ListItem>Russian Federation</asp:ListItem>
</
asp:DropDownList>
ListBox Control <asp:ListBox ID="ListBox2" runat="server">
<
asp:ListItem>India</asp:ListItem>
<
asp:ListItem>United States</asp:ListItem>
<
asp:ListItem>United Kingdom</asp:ListItem>
<
asp:ListItem>Turkey</asp:ListItem>
</
asp:ListBox>

The CheckBox and CheckBoxList Server Controls

A check box control provides freedom to user to select one or more option from web page. CheckBox control provides a single check box on the Webpage. Whereas the CheckBoxList control provides a collection of item on a webpage.

Some properties of CheckBox and CheckBoxList control are :
  • Text: Sets the text for the CheckBox control.

  • TextAlign: Sets the alignment of the text for the ChecBox and CheckBoxList controls.

  • Items: Accesses individual check boxes in the CheckBoxList control.

The RadioButton and RadioButtonList Server Control

The RadioButton server control places a single radio button on your Webpage. The RadioButtonList server control displays a collection of radio buttons on a Webpage. Usually radio buttons are used in a group. A user can select only one radio button in a group.
♦ If you use RadioButton server control in a web page, you should assign them a group manually by using GroupName property.
♦ If you uses RadioButtonList control in a page,then this control are grouped by default.

Some properties of the RadioButton and RadioButtonList controls are :
  • Text : Sets the text of the RadioButton control.

  • TextAlign : Sets the alignment of the text property of RadioButton and RadioButtonList server control.

  • Items : Accesses the individual check boxes in the RadioButtonList control.
Control ExampleOutput
CheckBox Control <asp:CheckBox ID="CheckBox2" runat="server" Text="English" />
CheckBoxList Control <asp:CheckBoxList ID="CheckBoxList2" runat="server">
<
asp:ListItem>English</asp:ListItem>
<
asp:ListItem>Punjabi</asp:ListItem>
<
asp:ListItem>Hindi</asp:ListItem>
<asp:ListItem>
Other</asp:ListItem>
</
asp:CheckBoxList>



RadioButtonControl <asp:RadioButton ID="RadioButton2" runat="server" Text="Indian" />
RadioButtonList Control <asp:RadioButtonList ID="RadioButtonList2" runat="server"> <asp:ListItem>Asia</asp:ListItem>
<
asp:ListItem>Africa</asp:ListItem>
<
asp:ListItem>Europe</asp:ListItem>
</
asp:RadioButtonList>


  
DMCA.com Protection Status
Design & Maintain By solvingera group| solvingera.com © 2013-2014 | all right reserved |Privacy Policy | Back to top