ASP編程入門進階(十三):Ad & Content Rotator

來源:互聯網
上載者:User
編程 ASP的強大不僅僅局限於接受和顯示的互動,更多的是運用ActiveX 組件進行更強大的Web應用。

那究竟ActiveX組件為何物?它又是如何運作的呢?其實ActiveX Server Components(ActiveX 伺服器組件)是一個存在於 WEB 伺服器上的檔案,該檔案包含執行某項或一組任務的代碼,組件可以執行公用任務,這樣就不必自己去建立執行這些任務的代碼。很形象的一句話:運用組件直接採用別人經典的功能強大的程式。只不過這程式已被封裝了的。

那具體ActiveX組件是如何產生、如何得來的呢?一般由下面三個路徑獲得:
1,安裝完IIS伺服器以後,內建的一些內建群組件,如Database Access資料庫連接組件。
2,從第三方開發人員處獲得可選的組件,或者免費或者收費的,如一些上傳組件(當然現在有無組件上傳)。
3,如果你是一位Web程式開發人員,可以使用Visual Basic 、Java 、Visual C++ 、COBOL等程式設計語言來編寫你所需要的ActiveX Server Component。這也就是所謂的ASP進行COM(Component Object Model)、COM+開發了。

當然無論是第三方還是自行開發,在使用之前都必須要進行系統的註冊。不過這些都是後話。我們現在需要的,是儘快先把ASP內建的一些組件搞懂吧。

不過在使用內建群組件之前,先用一個程式檢測一下自己機器中的組件支援情況。
引用一段網上流行的“阿江ASP探針”,將下列代碼儲存為asp檔案進行調試查看。

1,objcheck.asp

<%Option Explicit %>
<%
Dim filename
filename=Request.ServerVariables("SCRIPT_NAME")

Dim ObjTotest(14,4)
ObjTotest(0,0) = "MSWC.AdRotator"
ObjTotest(0,1) = "廣告輪顯組件"
ObjTotest(1,0) = "MSWC.ContentRotator"
ObjTotest(1,1) = "內容輪顯組件"
ObjTotest(2,0) = "MSWC.BrowserType"
ObjTotest(2,1) = "瀏覽器類型顯示組件"
ObjTotest(3,0) = "MSWC.NextLink"
ObjTotest(4,0) = "MSWC.Tools"
ObjTotest(5,0) = "MSWC.Status"
ObjTotest(6,0) = "MSWC.Counters"
ObjTotest(7,0) = "MSWC.IISLog"
ObjTotest(8,0) = "MSWC.PermissionChecker"
ObjTotest(9,0) = "Microsoft.XMLDom"
ObjTotest(10,0) = "IISSample.ContentRotator"
ObjTotest(11,0) = "IISSample.PageCounter"
ObjTotest(12,0) = "Scripting.FileSystemObject"
ObjTotest(13,0) = "adodb.connection"

public IsObj,VerObj,TestObj

dim i
for i=0 to 13
on error resume next
IsObj=false
VerObj=""
TestObj=""
set TestObj=server.CreateObject(ObjTotest(i,0))
If IsObject(TestObj) then
IsObj = True
VerObj = TestObj.version
if VerObj="" or isnull(VerObj) then VerObj=TestObj.about
end if
ObjTotest(i,2)=IsObj
ObjTotest(i,3)=VerObj
next

sub ObjTest(strObj)
on error resume next
IsObj=false
VerObj=""
TestObj=""
set TestObj=server.CreateObject (strObj)
If IsObject(TestObj) then
IsObj = True
VerObj = TestObj.version
if VerObj="" or isnull(VerObj) then VerObj=TestObj.about
end if
End sub
%>
<title>Object Check</title>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#cccccc" width=80%>
<tr align=center><td width=40%>組 件 名 稱</td><td width=40%>相 關 信 息</td></tr>
<%For i=0 to 13%>
<tr>
<td> <%=ObjTotest(i,0) & " <font color=#888888>" & ObjTotest(i,1)%></font></td>
<td> 
<%
If Not ObjTotest(i,2) Then
Response.Write "<font color=red>不支援</font>"
Else
Response.Write "支援," & left(ObjTotest(i,3),22)
End If%></td>
</tr>
<%next%>
</table>

<FORM action=<%=filename%> method=post>
<input type=text name="classname" size=40>
<INPUT type=submit value=" 確 定 ">
</FORM>

<%
Dim strClass
strClass = Trim(Request.Form("classname"))
If strClass <> "" then
Response.Write "<br>您指定的組件的檢查結果:"
Dim Verobj1
ObjTest(strClass)
If Not IsObj then
Response.Write "<br><font color=red>很遺憾,該伺服器不支援 " & strclass & " 組件!</font>"
Else
if VerObj="" or isnull(VerObj) then
Verobj1="無法取得該組件版本"
Else
Verobj1="該組件版本是:" & VerObj
End If
Response.Write "<br><font class=fonts>恭喜!該伺服器支援 " & strclass & " 組件。" & verobj1 & "</font>"
End If
End if
%>
[Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]

如果你可以運行該ASP檔案,也就是說你擁有IIS的WEB服務了。既然有IIS,不出意外,我們今天要學



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.