Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

Asp.net: Overview of ASP.NET Controls

by the3factory 2/27/2008 8:39:00 AM
The ASP.NET Framework  contains over 80 controls. These controls can be divided into eight groups:
  • Standard Controls The standard controls enable you to render standard form elements such as buttons, input fields, and labels.

  • Validation Controls The validation controls enable you to validate form data before you submit the data to the server. For example, you can use a RequiredFieldValidator control to check whether a user entered a value for a required input field.

  • Rich Controls The rich controls enable you to render things such as calendars, file upload buttons, rotating banner advertisements, and multi-step wizards.

  • Data Controls The data controls enable you to work with data such as database data. For example, you can use these controls to submit new records to a database table or display a list of database records.

  • Navigation Controls The navigation controls enable you to display standard navigation elements such as menus, tree views, and bread crumb trails.

  • Login Controls The login controls enable you to display login, change password, and registration forms.

  • Web Part Controls The Web Part controls enable you to build personalizable portal applications.

  • HTML Controls The HTML controls enable you to convert any HTML tag into a server-side control.

With the exception of the HTML controls, you declare and use all the ASP.NET controls in a page in exactly the same way. For example, if you want to display a text input field in a page, then you can declare a TextBox control like this:

<asp:TextBox id="TextBox1" runat="Server" />

This control declaration looks like the declaration for an HTML tag. Remember, however, unlike an HTML tag, a control is a .NET class that executes on the server and not in the web browser.

When the TextBox control is rendered to the browser, it renders the following content:

<input name="TextBox1" type="text" id="TextBox1" />

The first part of the control declaration, the asp: prefix, indicates the namespace for the control. All the standard ASP.NET controls are contained in the System.Web.UI.WebControls namespace. The prefix asp: represents this namespace.

Next, the declaration contains the name of the control being declared. In this case, a TextBox control is being declared.

This declaration also includes an ID attribute. You use the ID to refer to the control in the page within your code. Every control must have a unique ID.

Note

You should always assign an ID attribute to every control even when you don't need to program against it. If you don't provide an ID attribute, then certain features of the ASP.NET Framework (such as two-way databinding) won't work.


The declaration also includes a runat="Server" attribute. This attribute marks the tag as representing a server-side control. If you neglect to include this attribute, then the TextBox tag would be passed, without being executed, to the browser. The browser would simply ignore the tag.

Finally, notice that the tag ends with a forward slash. The forward slash is shorthand for creating a closing </asp:TextBox> tag. You can, if you prefer, declare the TextBox control like this:

<input name="TextBox1" type="text" id="TextBox1"></asp:TextBox>

In this case, the opening tag does not contain a forward slash and an explicit closing tag is included.

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0