The above code illustrates the limitations of the classic asp: the code block must be placed where you want the output to appear.
With classic ASP It is impossible to separate executable code from HTML itself. This makes web pages difficult to read and difficult to maintain.
asp.net-server control
Asp. NET has resolved the "Spaghetti code" problem, as described in the server control above.
The server's control tag is understood by the server.
There are three types of server controls:
HTML server Controls-Traditional H tml tags
Web server Control-the new a SP. NET Label
Validating server controls-for input validation
Asp.net-h tml Server Control
HTML server control HTML tag to understand the server.
HTML elements in the ASP.net file, by default, are treated as text. To enable these elements to be programmable, add runat = "server"
The HTML element for the property. This property indicates that the
, the content should be treated as a single server control. This property increases the identification of server controls. The reference ID can be used to manipulate the control server at run time.
Note: All HTML server controls must be in the runat = "server" attribute of a <form> tag. The runat = "server" property indicates that the
form should be processed on the server. The report also notes that the attached control can be passed through the server's script.
In the following example, we declare HtmlAnchor server-controlled. aspx file. And then
We manipulated the href attribute's HtmlAnchor control in an event handler (an event handler is a subroutine executing code for a particular event)
。 The Page_Load event is an event that many asp.net understand:
<script runat= "Server" >
Sub Page_Load
Link1. Href=http://www.111cn.net End
Sub
</script>
<form runat= "Server" >
<a id= "Link1" runat= "Server" >visit 111cn.net!</a>
</form>
</body>