asp常 用 代 碼

- 中國WEB開發者網絡 (http://www.webasp.net)
-- 技術教程 (http://www.webasp.net/article/)
--- asp常 用 代 碼 (http://www.webasp.net/article/15/14569.htm)
-- 作者:未知
-- 發佈日期: 2004-11-05
顯示頁面加載時間

頁面頂部添加下面的代碼:

<%
Dim strStartTime
Dim strEndTime

strStartTime = Timer '開始時間
%>

頁面(同一頁)的末尾添加:

<%
' 加載完畢的時間
strEndTime = Timer

Response.Write ("頁面加載時間: ")

Response.Write FormatNumber(strEndTime - strStartTime, 4)
Response.Write (" 秒.")
%>

顯示字符串前20個字符並在結尾處添加「……」

<%
Dim CutShort
CutShort = rsYourRecordset.Fields.Item("YourField").Value
Response.Write LEFT (CutShort, 20) & "........"
%>

如果動態圖片為空,用默認圖片代替

<%
Dim PicShow
PicShow = rsShowHide.Fields.Item("shMainPix").Value
IF PicShow <>"" THEN %>
<img src="<%=rsShowHide.Fields.Item("shMainPix").Value%>">
<% ELSE %>
<img src="StaticPic.gif">
<% End If %>



webasp.net