网页发展史大致可以分成下面三个阶段: HTML(HyperText Markup Language) ASP(Active Server Page) ASP.NET (著名的web设计开发语言还有JSP、PHP等)ASP的缺点: 一件工作要多个程序来完成 不是所有的都是面向对象的程序语言 未做到输入资料的验证(需要自己单独写) 未做到网页的信息安全 不支持XMLASP.NET改进了ASP的缺点,ASP.NET程序包含四大部分:
指引区域(directive block):夹在”<%@….%>”中
.NET代码区域(code declaration block):夹在”<script ….>”和”</script>”中
网页标签区域(tag block):夹在”<html>”和”</html>”中
动态标签区域(code render block):夹在”<%….%>”中
<%@ Page Language="VB" %> 指引区域 <script runat="server"> .NET代码区域 sub SavHi(obj as Object, e as EventArgs) lblMessage.Text = "Hi, " + tbName.Text + "你好" end sub </script> <html> 网页标签区域 <head></head> <body> <%Response.write("第一个ASP.NET程序")%> 动态标签区域 <br> <asp:Label id="lblMessage" runat="server" Text="看过来" /><br> <form runat="server"> 请输入姓名:<asp:TextBox id="tbName" runat="server" /><br> <asp:Button Text="发送" Onclick="SavHi" runat="server" /> </form> </body> </html>ASP.NET的标签: HTML Controls List Controls Rich Controls Validation Controls Web Controls
HTML Controls List Controls Rich Controls Validation Controls Web Controls HtmlAnchor DataGrid AdRotator CompareValidator Button HtmlButton DataList Calendar CustomValidator CheckBox HtmlForm Repeater Xml RangeValidator CheckBoxList HtmlGenericControl RegularExpressionValidator DropDownList HtmlImage RequiredFieldValidator HyperLink HtmlInputButton ValidationSummary Image HtmlInputCheckBox ImageButton HtmlInputFile Label HtmlInputHidden LinkButton HtmlInputImage ListBox HtmlInputRadioButton Panel HtmlInputText RadioButton HtmlSelect RadioButtonList HtmlTable Table HtmlTableCell TableCell HtmlTableRow TableRow HtmlTextArea TextBox
.NET代码区域和动态标签区域所用的语言都是Script语言,但是执行机制却不同。当用浏览器浏览网页程序代码时,ASP.NET先编译网页程序,其中: .NET代码区域,就会被编译成Object code,所谓的Microsoft Intermediate Language码,简称MSIL码,此MSIL码是储存在server中,只是为了让网页程序能快速的被执行。 编译程序对网页标签区域的处理是将所有的标签都转换成HTML标签,如果原来就是HTML的标签则不会有变化,若是ASP.NET的标签就会被转换成HTML标签。 编译程序对动态标签区域的程序代码不是作compile,而是做interpret的动作,也就是动态标签区域的代码立即被解译成HTML标签,和转换后的网页标签区域一起传送到client端的浏览器。
转换后的代码:
<html><head></head><body> 第一个ASP.NET程序 <br> <form name="ct10" method="post" action="test.aspx" id="_ct10"> <input type="hidden" name="_VIEWSTATE" value="dDwtNjIxOTc5MzA1O3Q8O2w8aTwwPjs+O2w8dDxwPHA8bDxUZXh0Oz47bDxIaSwg=" /> 请输入姓名:<input name="tbName" type="text" id="tdName" /> <br> <input type="submit" name="_ct1" value="发送"> </form></body></html>