ASP.NET server controls overview
This article was previously published under Q306459 This article refers to the following Microsoft .NET
Framework Class Library namespaces:
On This PageSUMMARY This article provides an introduction to the ASP.NET server
controls. For additional ASP.NET overviews, refer to the following Microsoft Knowledge Base article: 305140 (http://support.microsoft.com/kb/305140/EN-US/) INFO: ASP.NET Roadmap
MORE INFORMATION The ASP.NET page framework includes a number of built-in
server controls that are designed to provide a more structured programming
model for the Web. These controls provide the following features:
HTML Server ControlsThe HTML server controls are Hypertext Markup Language (HTML) elements that include a runat=server attribute. The HTML server controls have the same HTML output and the same properties as their corresponding HTML tags. In addition, HTML server controls provide automatic state management and server-side events. HTML server controls offer the following advantages:
To use an HTML server control, use the following syntax (which uses the HtmlInputText control as an example): For more information about individual HTML server controls that are
available in ASP.NET, refer to the following Microsoft Web sites: HtmlAnchor Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlanchorcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlanchorcontrol.asp) HtmlButton Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlbuttoncontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlbuttoncontrol.asp) HtmlForm Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlformcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlformcontrol.asp) HtmlImage Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlimagecontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlimagecontrol.asp) HtmlInputButton Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputbuttoncontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputbuttoncontrol.asp) HtmlInputCheckBox Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputcheckboxcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputcheckboxcontrol.asp) HtmlInputFile Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputfilecontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputfilecontrol.asp) HtmlInputHidden Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputhiddencontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputhiddencontrol.asp) HtmlInputImage Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputimagecontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputimagecontrol.asp) HtmlInputRadioButton Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputradiobuttoncontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputradiobuttoncontrol.asp) HtmlInputText Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputtextcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlinputtextcontrol.asp) HtmlSelect Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlselectcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmlselectcontrol.asp) HtmlTable Control http://msdn2.microsoft.com/en-us/library/2962t2k8(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/2962t2k8(vs.71).aspx) HtmlTableCell Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmltablecellcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmltablecellcontrol.asp) HtmlTableRow Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmltablerowcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmltablerowcontrol.asp) HtmlTextArea Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmltextareacontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhtmltextareacontrol.asp) Web Server ControlsWeb controls are very similar to the HTML server controls such as Button, TextBox, and Hyperlink, except that Web controls have a standardized set of property names. Web server controls offer the following advantages:
To use a Web server control, use the following syntax (which uses the TextBox control as an example): Web server controls can be divided into four categories:
Basic Web ControlsBasic Web controls provide the same functionality as their HTML server control counterparts. However, basic Web control include additional methods, events, and properties against which you can program.For more information about individual Web controls that are available in ASP.NET, refer to the following Microsoft Web sites:
Button Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconbuttonwebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconbuttonwebcontrol.asp) CheckBox Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcheckboxwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcheckboxwebservercontrol.asp) HyperLink Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhyperlinkwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconhyperlinkwebservercontrol.asp) Image Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconimagewebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconimagewebservercontrol.asp) ImageButton Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconimagebuttonwebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconimagebuttonwebcontrol.asp) Label Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconlabelwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconlabelwebservercontrol.asp) LinkButton Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconlinkbuttonwebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconlinkbuttonwebcontrol.asp) Literal Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gnconliteralwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gnconliteralwebservercontrol.asp) Panel Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconpanelwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconpanelwebservercontrol.asp) PlaceHolder Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gnconplaceholderwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gnconplaceholderwebservercontrol.asp) RadioButton Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconradiobuttonwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconradiobuttonwebservercontrol.asp) Table Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcontablewebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcontablewebcontrol.asp) TableCell Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcontablecellwebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcontablecellwebcontrol.asp) TableRow Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcontablerowwebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcontablerowwebcontrol.asp) TextBox Web Server Control http://msdn2.microsoft.com/en-us/library/fhc2c904(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/fhc2c904(vs.71).aspx) Validation ControlsValidation controls are used to validate the values that are entered into other controls of the page. Validation controls perform client-side validation, server-side validation, or both, depending on the capabilities of the browser in which the page is displayed. Validation controls offer the following advantages:
RequiredFieldValidator Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconrequiredfieldvalidatorcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconrequiredfieldvalidatorcontrol.asp) RangeValidator Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconrangevalidatorcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconrangevalidatorcontrol.asp) CompareValidator Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcomparevalidatorcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcomparevalidatorcontrol.asp) RegularExpressionValidator Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconregularexpressionvalidatorcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconregularexpressionvalidatorcontrol.asp) CustomValidator Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcustomvalidatorcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcustomvalidatorcontrol.asp) ValidationSummary Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconvalidationsummarycontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconvalidationsummarycontrol.asp) List ControlsList controls are special Web server controls that support binding to collections. You can use list controls to display rows of data in a customized, templated format. All list controls expose DataSource and DataMember properties, which are used to bind to collections.List controls can bind only to collections that support the IEnumerable, ICollection, or IListSource interfaces. For example, a Microsoft Visual C# .NET sample page appears as follows: A Microsoft Visual Basic .NET sample page appears as follows: The output appears as follows:
one
For more information about individual list controls that are
available in ASP.NET, refer to the following Microsoft Web sites: two three
ListBox Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconlistboxwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconlistboxwebservercontrol.asp) CheckBoxList Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcheckboxlistwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcheckboxlistwebservercontrol.asp) RadioButtonList Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconradiobuttonlistwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconradiobuttonlistwebservercontrol.asp) Repeater Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconrepeaterwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconrepeaterwebservercontrol.asp) DataList Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcondatalistwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcondatalistwebservercontrol.asp) DataGrid Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconDataGridWebControl.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconDataGridWebControl.asp) DropDownList Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcondropdownlistwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcondropdownlistwebservercontrol.asp) Rich ControlsIn addition to the preceding controls, the ASP.NET page framework provides a few, task-specific controls called rich controls. Rich controls are built with multiple HTML elements and contain rich functionality. Examples of rich controls are the Calendar control and the AdRotator control.For more information about individual rich controls that are available in ASP.NET, refer to the following Microsoft Web sites:
AdRotator Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconadrotatorwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconadrotatorwebservercontrol.asp) Calendar Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcalendarwebcontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcalendarwebcontrol.asp) Xml Web Server Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gnconxmlwebservercontrol.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gnconxmlwebservercontrol.asp) User ControlsOften, you may want to reuse the user interface of your Web Form without having to write any extra code. ASP.NET enables you to do this by converting your Web Forms into user controls. User controls, which have the .ascx file extension, can be used multiple times within a single Web Form.To convert a Web Form into a user control, follow these steps:
Web Forms User Controls http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconwebformsusercontrols.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconwebformsusercontrols.asp) Custom ControlsIn addition to the built-in Web controls, ASP.NET also allows you to create your own custom controls. It may be useful to develop custom controls if you are faced with one of these scenarios:
Developing ASP.NET Server Controls http://msdn2.microsoft.com/en-us/library/aa719973(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/aa719973(vs.71).aspx) Developing Custom Controls: Key Concepts http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconkeyconceptsinwebformscontroldevelopment.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconkeyconceptsinwebformscontroldevelopment.asp) Developing a Composite Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingcompositecontrols.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingcompositecontrols.asp)
| Article Translations
|
Back to the top
