Introducing ASP.NET Server Controls

Posted on January 30, 2007. Filed under: controls, introduction |

Today I’m learning about server controls. What, why and how? There’s two types, HTML Server Controls and Web Server Controls. Both types must be wrapped by a single <form runat="server"> tag.

Intrinsic HTML Server Controls

Intrinsic server controls are standard HTML tags containing a runat="server" attribute. For example:

<input type="text" id="name" runat="server" />

This creates an HtmlInputText server control and is accessible in your code using name.Value.

Web Server Controls

ASP.NET offers a rich set of custom controls that generate HTML content for you. Instead of the above HTML <input> element, the equivalent control is:

<asp:TextBox id="name" runat="server" />

The web server controls come with a lot more power though. For example, we can customise the TextBox control:

<asp:TextBox id="name" runat="server" TextMode="Password" Columns="40" />

In this case, the TextMode property is set so it hides the text entered into the text field. The Columns property sets the size attribute of the HTML input tag that ASP.NET generates.

More Advanced Controls

Microsoft have a small tutorial on each web server control ASP.NET offers. Included are list controls – DropDownList, ListBox and RadioButtonList – and more advanced controls such as Calendar and Wizard.

Make a Comment

Make a Comment: ( 1 so far )

blockquote and a tags work here.

One Response to “Introducing ASP.NET Server Controls”

RSS Feed for dotnetting Comments RSS Feed

You may include the overview of Microsoft ASP.NET Ajax Control toolkit too. It gonna increase the topic’s value.


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...