NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

HTML Controls

HTML controls offer Web developers the power of the Web Forms page framework while retaining the familiarity and ease of use of HTML elements. These controls look exactly like HTML, save that they have a runat="server" attribute/value pair in the opening tag of an HTML element. For example, the following HTML would not only create a text box on a Web page, but would also create an instance of the HtmlInputText server control:

<input id="MyTextBox" type="text" runat="server">

Without runat="server", this line of HTML would be parsed into a standard text box. This model allows developers to import an HTML page authored by a Web designer and program against selected elements on the page. In addition, once an element is converted to a control, a NGWS class is created for the element and its attributes are exposed as properties on the HTML control. For information about these classes, see the System.Web.UI.HtmlControls Namespace reference.

To enable programmatic referencing of the control, developers can include a unique id attribute. In the example above, the id="MyTextBox" defines this programmatic ID, allowing developers to manipulate the contents of this text box with events and other code that they write.

ASP+ offers direct object model support for the most commonly used HTML elements. For those that are not directly supported, there is the HtmlGenericControl, which supports the <span>, <div>, <body>, and <font> elements, among others.

In addition, HTML controls offer the following features:

General Rules for Using HTML Controls

<form runat="server" id="myForm">
   <input type="text" id="myTextBox" runat="server">
   <input type="submit" id="mySubmitButton" onServerClick="SubmitBtn_Click" runat="server">
</form>

See Also

Web Forms Server Controls | Web Controls | Web Forms Controls by Function | Validation Controls | System.Web.UI.HtmlControls Namespace