asp+的幾個(gè)特點(diǎn)(一)
發(fā)表時(shí)間:2024-02-15 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]關(guān)于Asp+的幾個(gè)特點(diǎn) 翻譯:jjx (http://www.cnscript.com) 轉(zhuǎn)載請(qǐng)說(shuō)明出處 原文: http://www.asptoday.com/articles/20000712.htm 來(lái)自: http://www.cnscript.com/activeubb/newsdeta...
關(guān)于Asp+的幾個(gè)特點(diǎn)
翻譯:jjx (http://www.cnscript.com) 轉(zhuǎn)載請(qǐng)說(shuō)明出處 原文: http://www.asptoday.com/articles/20000712.htm
來(lái)自: http://www.cnscript.com/activeubb/newsdetail.asp?id=1656
1、缺省語(yǔ)言
在Asp+中,將使用Visual Basic而不是VBScript為缺省語(yǔ)言。這意味著我們可以擺脫vbscript的語(yǔ)言限制,我們的代碼將
是編譯后運(yùn)行的(而不是原來(lái)的解釋執(zhí)行)。這意味asp+頁(yè)面具有組件方式的性能。cool
2、服務(wù)器端控件
一個(gè)客戶端控件
<SELECT id="selOpSys" size="1" >
<OPTION>Windows 95</OPTION>
<OPTION>Windows 98</OPTION>
<OPTION>Windows NT4</OPTION>
<OPTION>Windows 2000</OPTION>
</SELECT>
加上runat=Server就變成服務(wù)器端控件
<SELECT id="selOpSys" size="1" runat="server">
<OPTION>Windows 95</OPTION>
<OPTION>Windows 98</OPTION>
<OPTION>Windows NT4</OPTION>
<OPTION>Windows 2000</OPTION>
</SELECT>
服務(wù)器端控件能在服務(wù)器端腳本中被自由運(yùn)用
傳統(tǒng)的asp代碼
...
If Len(Request.Form("selOpSys")) > 0 Then
strOpSys = Request.Form("selOpSys")
strName = Request.Form("txtName")
Response.Write("You selected '" & strOpSys _
& "' for machine '" & strName & "'.")
End If
asp+代碼
If Len(selOpSys.value) > 0 Then
Response.Write("You selected '" & selOpSys.value _
& "' for machine '" & txtName.value & "'.")
End If
一個(gè)服務(wù)器端的form 代碼
<FORM runat="server">
Machine Name:
<INPUT type="text" id="txtName" runat="server">
<P />
Operating System:
<select id="selOpSys" size="1" runat="server">
<OPTION>Windows 95</OPTION>
<OPTION>Windows 98</OPTION>
<OPTION>Windows NT4</OPTION>
<OPTION>Windows 2000</OPTION>
</SELECT>
<P />
<INPUT type="submit" value="Submit">
</FORM>
運(yùn)行后將自動(dòng)被解釋成客戶端代碼
<HTML>
<BODY>
You selected 'Windows 98' for machine 'tizzy'.
<FORM name="ctrl0" method="post" action="pageone.aspx" id="ctrl0">
<INPUT type="hidden" name="__VIEWSTATE" value="a0z1741688109__x">
Machine Name:
<INPUT type="text" id="txtName" name="txtName" value="tizzy">
<P />
Operating System:
<SELECT id="selOpSys" size="1" name="selOpSys">
<OPTION value="Windows 95">Windows 95</OPTION>
<OPTION selected value="Windows 98">Windows 98</OPTION>
<OPTION value="Windows NT4">Windows NT4</OPTION>
<OPTION value="Windows 2000">Windows 2000</OPTION>
</SELECT>
<P />
<INPUT type="submit" value="Submit">
</FORM>
</BODY>
</HTML>
三、服務(wù)器端事件
服務(wù)器端控件具有事件,可以像操作客戶端事件一樣操作服務(wù)器端事件,asp+自動(dòng)翻譯服務(wù)器端事件到客戶端
舉例:
onserverclick事件
<HTML>
<BODY>
<SCRIPT language="VB" runat="server">
Sub ShowValues(Sender As Object, Args As EventArgs)
divResult.innerText = "You selected '" _
& selOpSys.value & "' for machine '" _
& txtName.value & "'."
End Sub
</SCRIPT>
<DIV id="divResult" runat="server"></DIV>
<FORM runat="server">
Machine Name:
<INPUT type="text" id="txtName" runat="server">
<P />
Operating System:
<select id="selOpSys" size="1" runat="server">
<OPTION>Windows 95</OPTION>
<OPTION>Windows 98</OPTION>
<OPTION>Windows NT4</OPTION>
<OPTION>Windows 2000</OPTION>
</SELECT>
<P />
<INPUT type="submit" value="Submit"
runat="server" onserverclick="ShowValues">
</FORM>
</BODY>
</HTML>
(出處:熱點(diǎn)網(wǎng)絡(luò))