How to: Add HTML Server Controls to a Web Page Using ASP.NET Syntax

Adding HTML server controls is like adding any HTML element, except that you convert the element to a control so that you can work with it in server code.


For information about controls for ASP.NET Web pages, see Introduction to ASP.NET Server Controls.

You can add an HTML server control to a page by declaring it directly in the .aspx file.

To add an HTML server control

  • Type the HTML syntax of the element you want to use as a control. Include the normal HTML syntax for the element, and in addition, do the following:

    • Set the control's ID attribute (property) to a unique value for that page, unless the control is part of a complex control and will be repeated (as in Repeater, DataList, and GridView controls).

    • Set the runat="server" attribute to convert the element to a control.

    The following example shows how to declare an HtmlInputText control, HtmlInputText control, an HtmlInputButton control, and an HtmlAnchor control:

    No code example is currently available or this language may not be supported.

    For information about the declarative syntax for a specific HTML server control, see HTML Server Controls.

See Also

Community Additions