HTML server control tags insert standard HTML elements as accessible server controls.
<HTMLTag [id=”OptionalName”] [attribute="value" ...] runat="server"> [</HTMLTag>]
By default, HTML tags within an ASP+ file are treated as literal text and are programmatically inaccessible to page developers. You can indicate that an HTML tag should be parsed and treated as an accessible server control by adding a runat attribute with a value of “server”. A unique id attribute enables programmatic referencing of the control. Name/value attributes are used to declare property arguments and event bindings on server control instances.
HTML server controls must reside within a containing <form>
control with the runat="server"
attribute/value pair. The <form>
control itself is exempt from this requirement.
ASP+ does not require literal (non-dynamic) HTML content to be well-formed, but it does require that all non-closed HTML tags be properly closed (either with a trailing “/” or an end tag) and cleanly nested (overlapping tags are not allowed).
If an HTML tag that is not supported (such as <body>
, <span>
, or <div>
) is marked with a runat="server"
attribute/value pair, ASP+ will use the generic HTMLControl class.
For a list of supported controls, see Supported HTML Server Controls.
The following simple page shows the use of several HTML server controls:
<html> <head> <script runat="server" language="VB"> Sub FruitList_Click( Source As Object, _ E As EventArgs ) FruitName.InnerHTML= FruitList.Value FruitImage.src= "images\" & FruitList.Value & ".jpg" End Sub </script> </head> <body> <form runat="server"> <font face="Verdana"> <b>Please Select A Fruit: </b> <select id="FruitList" runat="server" size="1"> <option value="Orange">Orange</option> <option value="Apple">Apple</option> <option value="Mango">Mango</option> <option value="Pear">Pear</option> <option value="Banana">Banana</option> </select> <input type="submit" value="submit" runat="server" OnServerClick="FruitList_Click"> <p> <table><tr><td> <img id="FruitImage" src="images\blank.gif" runat="server" /> </td><td> <font face="Verdana" size=6> <span id="FruitName" runat="server"/> </font> </td></tr></table></font> </form> </body> </html>
ASP+ Page Syntax