[ÕªÒª]ASPÓïÑÔµÄÌصã 1.ÔÊÐíʹÓÃVBscript»òJavascript¼òÒ×ScriptÓïÑÔ£¬²¢¿ÉÔÚÎļþÖнáºÏHtml£» 2.ÎÞÐè±àÒ룬ÓÉWEBserverÖ´ÐвúÉú£» 3.ÓëÈκÎActiveX Script¼æÈÝ£» 4.ASPÔʼ´úÂë²»»á´«µ½¿Í»§¶Ë£¬¿Í»§¶ËÏÔʾµÄÊÇÖ´Ðнá¹û¡£ <Form>±íµ¥...
ASPÓïÑÔµÄÌصã
1.ÔÊÐíʹÓÃVBscript»òJavascript¼òÒ×ScriptÓïÑÔ£¬²¢¿ÉÔÚÎļþÖнáºÏHtml£»
2.ÎÞÐè±àÒ룬ÓÉWEBserverÖ´ÐвúÉú£»
3.ÓëÈκÎActiveX Script¼æÈÝ£»
4.ASPÔʼ´úÂë²»»á´«µ½¿Í»§¶Ë£¬¿Í»§¶ËÏÔʾµÄÊÇÖ´Ðнá¹û¡£
<Form>±íµ¥Óï·¨£º
<Form name="StrName" id="StrId" action="" method="post/get">content</Form>;
<Input>ÀàÐÍ£º
<input type=text name="StrName" value="StrValue" size="num" maxlength="num" [disable]>;
<input type=password name="StrName" value="StrValue">;
<input type=radio name="StrName" value="StrValue" [checked]>;
<input type=checkbox name="StrName" value="StrValue" [checked]>;
<INPUT type=file NAME="StrName" SIZE="20">
<input type=hidden name="StrName" value="StrValue">
<input type="submit" name="StrName" value="StrValue">
<input type="reset" name="StrName" value="StrValue">
<input type="button" name="StrName" value="StrValue">
<select name="StrName" [multiple]><option value="StrValue" selected>text[<option>n]</select>
<textarea name="StrName" rows="num" cols="num">text</textarea>
<frameset>Óï·¨£º
<frameset rows/cols="num,num/*.."><frame name="StrName" src="StrSrc">[<frame>n [<frameset>..</frameset>]]</frameset>
<noframe><body>warning!</body></noframe> ÎÞ¿ò¼ÜÌáʾ;
¿ØÖÆ¿ò¼ÜÄÚÈÝ£º<a href="StrSrc" target="StrFrameName"> ¾Í¿ÉÒÔÁË¡£
ÓÃ
javascript: Document.frame.StrFrameName.Location="StrSrc";
VBscript³£Óú¯Êý£º
1.ÊýÖµÐͺ¯Êý£º
abs(num): ·µ»Ø¾ø¶ÔÖµ
sgn(num): num>0 1; num=0 0; num<0 -1;ÅжÏÊýÖµÕý¸º
hex(num): ·µ»ØÊ®Áù½øÖÆÖµ Ö±½Ó±íʾ£º&Hxx ×î´ó8λ
oct(num): ·µ»Ø°Ë½øÖÆÖµ Ö±½Ó±íʾ£º&Oxx ×î´ó8λ
sqr(num): ·µ»Øƽ·½¸ù num>0
int(num): È¡Õû int(99.8)=99; int(-99.2)=100
fix(num): È¡Õû fix(99.8)=99; fix(-99.2)=99
round(num,n): ËÄÉáÎåÈëȡСÊýλ round(3.14159,3)=3.142 ÖеãÊýÖµËÄÉáÎåÈëΪ½üżȡÕû round(3.25,1)=3.2
log(num): È¡ÒÔeΪµ×µÄ¶ÔÊý num>0
exp(n): È¡eµÄn´ÎÃÝ Í¨³£Óà num^n
sin(num): Èý½Çº¯Êý£¬ÒÔ»¡¶ÈΪֵ¼ÆËã (½Ç¶È*Pai)/180=»¡¶È con(num); tan(num); atn(num)
2.×Ö·û´®º¯Êý£º
len(str)£º¼ÆËã×Ö·û´®³¤¶È ÖÐÎÄ×Ö·û³¤¶ÈÒ²¼ÆΪһ£¡
mid(str,Æðʼ×Ö·û,[¶ÁÈ¡³¤¶È])£º½ØÈ¡×Ö·û´®Öмä×Ó×Ö·û´®
left(str,nlen)£º´Ó×ó±ßÆð½ØÈ¡nlen³¤¶È×Ó×Ö·û´®
right(str,nlen)£º´ÓÓÒ±ßÆð½ØÈ¡nlen³¤¶È×Ó×Ö·û´®
Lcase(str)£º×Ö·û´®×ª³ÉСд
Ucase(str)£º×Ö·û´®×ª³É´óд
trim(str)£ºÈ¥³ý×Ö·û´®Á½¶Ë¿Õ¸ñ
Ltrim(str)£ºÈ¥³ý×Ö·û´®×ó²à¿Õ¸ñ
Rtrim(str)£ºÈ¥³ý×Ö·û´®ÓÒ²à¿Õ¸ñ
replace(str,²éÕÒ×Ö·û´®,Ìæ´ú×Ö·û´®,[Æðʼ×Ö·û,Ìæ´ú´ÎÊý,±È½Ï·½·¨])£ºÌæ»»×Ö·û´®
×¢£ºÄ¬ÈÏÖµ£ºÆðʼ×Ö·û 1£»Ìæ´ú´ÎÊý ²»ÏÞ£»±È½Ï·½·¨ Çø·Ö´óСд£¨0£©
InStr([Æðʼ×Ö·û,]str,²éÕÒ×Ö·û´®[,±È½Ï·½·¨])£º¼ì²âÊÇ·ñ°üº¬×Ó×Ö·û´® ¿ÉÑ¡²ÎÊýÐèͬʱѡ ·µ»ØÆðʼλÖÃ
InStrRev(str,²éÕÒ×Ö·û´®[,Æðʼ×Ö·û][,±È½Ï·½·¨])£º·´Ïò¼ì²âÊÇ·ñ°üº¬×Ó×Ö·û´® ·µ»ØÆðʼλÖÃ
space(n)£º¹¹Ôìn¸ö¿Õ¸ñµÄ×Ö·û´®
string(n,str)£º¹¹ÔìÓÉn¸östrµÚÒ»¸ö×Ö·û×é³ÉµÄ×Ö·û´®
StrReverse(str)£º·´×ª×Ö·û´®
split(str,·Ö¸î×Ö·û´®[,´ÎÊý][,±È½Ï·½·¨])£ºÒÔ·Ö¸î×Ö·û´®Îª·Ö¸î±êÖ¾½«×Ö·û´®×ªÎª×Ö·ûÊý×é ¿ÉÑ¡²ÎÊýÐèͬʱѡ
3.Êý¾ÝÀàÐÍת»»º¯Êý£º
Cint(str)£º×ª»»ÕýÊý True -1£»False 0£»ÈÕÆÚ ¾àÀë1899/12/31ÌìÊý£»Ê±¼ä ÉÏÎç¶Î 0£»ÏÂÎç¶Î 1£»
Cstr(str)£ºÈÕÆÚ Êä³ö¸ñʽ yyyy/mm/dd£»Ê±¼ä Êä³ö¸ñʽ Am/Pm hh:mm:ss
Clng(str)£ºÓëCin()ÀàËÆ
Cbool(num)£ºnum²»ÎªÁã True£»·´Ö® False
Cdate(str)£º×ª»»ÈÕÆÚ¸ñʽ 0£º#Am 12:00:00#£»ÕýÊý ¾àÀë1899/12/31ÌìÊýµÄÈÕÆÚ£»¸¡µãÊý ÈÕÆÚ£«Ð¡Êýʱ¼ä
Cbyte(num)£ºnum<255 ת»»Îª×Ö½Ú
Csng(str)£º×ª»»Îªµ¥¾«¶ÈÊýÖµ
Cdbl(str)£º×ª»»ÎªË«¾«¶ÈÊýÖµ
Ccur(str)£º×ª»»ÎªÏÖ½ð¸ñʽ
4.ʱ¼äº¯Êý£º
date£ºÈ¡ÏµÍ³µ±Ç°ÈÕÆÚ
time£ºÈ¡ÏµÍ³µ±Ç°Ê±¼ä
now£ºÈ¡ÏµÍ³µ±Ç°Ê±¼ä¼°ÈÕÆÚÖµ DatetimeÀàÐÍ
timer£ºÈ¡µ±Ç°Ê±¼ä¾àÀëÁãµãÃëÖµ£¬¼ÆʱÆ÷£¬¿É¼ÆËãʱ¼ä²î
DateAdd(¼ä¸ôµ¥Î»,¼ä¸ôÖµ,ÈÕÆÚ)£ºÍÆËãÏàÁÚÈÕÆÚ
DateDiff(¼ä¸ôµ¥Î»,ÈÕÆÚÒ»,ÈÕÆÚ¶þ)£º¼ÆËãʱ¼ä²î ÈÕÆÚ¶þ-ÈÕÆÚÒ»
Datepart(¼ä¸ôµ¥Î»,ÈÕÆÚ)£º¼ÆËãÈÕÆڵļä¸ôµ¥Î»Öµ
Dateserial(date)£ºÊä³öÈÕÆÚÖµ£¨°´ÐòÁмÆË㣩
Timeserial(time)£ºÊä³öʱ¼äÖµ£¨°´ÐòÁмÆË㣩
DateValue(datetime)£ºÈ¡³ö×Ö·û´®ÖÐÈÕÆÚÖµ
Timevalue(datetime)£ºÈ¡³ö×Ö·û´®ÖÐʱ¼äÖµ
weekday(date)£º¼ÆËãÐÇÆÚ¼¸
MonthName(date)£ºÊä³öÔ·ÖÃû
year(datetime)£º½ØÈ¡Äê·Ý
month(datetime)£º½ØÈ¡Ô·Ý
day(datetime)£º½ØÈ¡ÈÕ
hour(datetime)£º½ØȡСʱ
minute(datetime)£º½ØÈ¡·ÖÖÓ
second(datetime)£º½ØÈ¡Ãë
5.ÆäËüº¯Êý£º
Array(unit,..)£º¶¯Ì¬Éú³ÉÊý×é
Asc(str)£ºÊä³ö×Ö·û´®µÚÒ»¸ö×Ö·ûµÄASCIIÂë
Chr(asc)£º×ª»»ASCIIΪ×Ö·û Enter£ºChr(13)&Chr(10)
Filter(Êý×éÃû³Æ,¹Ø¼ü×Ö·û´®,[,°üº¬][,±È½Ï·½·¨])£º
½«×Ö·û´®Êý×éÖк¬Óйؼü×Ö·û´®µÄÔªËØ´æ³ÉеÄÊý×飨ĬÈÏ£© [°üº¬]ΪfalseÔòÈ¡²»°üº¬µÄÔªËØ
Join(ArrayName)£º½«Êý×éÖÐÔªËØÁ¬³É×Ö·û´®
Ubound(ArrayName[,άÊý])£ºÈ¡µÃÊý×éÏàӦάÊýµÄÉϽç
Lbound(ArrayName[,άÊý])£ºÈ¡µÃÊý×éÏàӦάÊýµÄϽç Ò»°ãΪ0
Randmize n£ºÆô¶¯Ëæ»úÊýÖÖ×Ó
Rnd(n)£ºÈ¡µÃËæ»úÊý£¬n>0»òΪ¿Õ£¬È¡ÐòÁÐÏÂÒ»Ëæ»úÖµ£¬n<0£¬Ëæ»úÖµÏàͬ£¬n=0£¬Éú²úÓëÉÏÒ»Ëæ»úÖµÏàͬµÄÊý
È¡½éÓÚAºÍBÖ®¼äµÄËæ»úÕýÊýC£¬¹«Ê½£ºC=Int((B-A+1)*Rnd+A) Ìõ¼þ£¨B>A£©
×Ó³ÌÐòºÍ×Ô¶¨Ò庯Êý
Sub StrSubName Function StrFunName(arg[1],..)
×Ó³ÌÐòÌå º¯ÊýÌå
Exit Sub ÖÐ;Ìø³ö Exit Function ÖÐ;Ìø³ö
End Sub StrFunName£½Value ·µ»ØÖµ
End Function
[call] StrSubName ÒýÓÃ×Ó³ÌÐò Var=StrFunName(arg[1],..) ÒýÓú¯Êý
×Ó³ÌÐòºÍ×Ô¶¨Ò庯Êý¿ÉÒԵݹéµ÷Óã»
ASPÁù´ó¶ÔÏó³£ÓÃÓï¾äʾ·¶£º
Response£º
Response.write StrVar/"String"£ºÏòÍøҳд³ö²ÎÊýÖµ»ò×Ö·û´® µÈͬÓÚÔÚHtml±ê¼ÇÖÐǶÈë<%=StrVar/"String"%>
Response.End£ºÍ£Ö¹Ò³Ãæ±àÒ룬²¢½«ÒѾ±àÒëÄÚÈÝÊä³öµ½ä¯ÀÀÆ÷
Response.Buffer=True False£ºÒ³Ãæ±àÒëʱÊÇ·ñʹÓûº´æµÄÉèÖã¬Ò»°ãÔÚÒ³ÃæÍ·²¿ÉèÖÃ
Response.Flush£ºÇ¿ÖÆÊä³öÒ³ÃæÒѱàÒ벿·ÖÄÚÈÝ
Response.Clear£º½«»º³åÇøÄÚµÄÊý¾ÝÇå³ý
Response.Redirect URL£ºÍ£Ö¹Ò³Ãæ±àÒë»òÊä³ö£¬×ªÔØÖ¸¶¨ËùÐèÒ³Ãæ
Response.IsClientConnected£º·µ»ØTrue False£¬¼ì²âÓû§ÊÇ·ñ»¹´¦ÓÚÁ¬½Ó״̬
Response.Charset(CharsetName)£ºÉèÖÃÒ³Ãæ±àÂëÀàÐÍ£¬¼´<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Response.ContentType [= ContentType ]£ºÉèÖÃÒ³ÃæÎļþÀàÐÍ£¬Í¬ÉÏ
Response.Expires [= number]£ºÉèÖÃÒ³ÃæʧЧʱ¼ä£¬µ¥Î»·ÖÖÓ
Response.ExpiresAbsolute [= [date] [time]]£ºÉèÖÃÒ³ÃæʧЧµÄ¾ø¶Ôʱ¼ä
Response.Status = StatusDescription£ºÉèÖÃÒ³Ãæ״̬ÃèÊö
Request£º
Request("PassStrName")£º¶ÁÈ¡ÍøÒ³´«µÝÖµ£¬°üÀ¨±íµ¥¼°ÒÔ£¿PassStrName£½value&PassStrName_n£½value_nÐÎʽ
Request[.collection property method](variable)
Request.querystring("PassStrName")£º¶ÁÈ¡Get·½·¨´«µÝµÄ±íµ¥ÖµºÍ£¿PassStrName£½value
Request.QueryString(Varible)[(Index).Count]
Request.form("PassStrName")£º¶ÁÈ¡Post·½·¨´«µÝµÄ´¿±íµ¥ÓòµÄÖµ
Request.Form(Parameter)[(Index).Count]
Request.ServerVaribles(Server Environment Variable)£º¶ÁÈ¡¿Í»§¶Ëϵͳ»·¾³±äÁ¿£¬Ïê¼û²Î¿¼
Request.BinaryRead(Count)£º¶ÁÈ¡Ö¸¶¨×Ö½ÚÊýµÄ´«ËÍÖµ
Request.TotalBytes£º²éѯÌåµÄ³¤¶È£¬ÒÔ×Ö½ÚΪµ¥Î»£¬Ö»¶Á
×¢£ºÍ¬Ãû±íµ¥È磺CheckBoxÈçÓжàÏîÖµ£¬´«µÝÐÎʽÈçÓÒ£¬StrName=value1,value2,...ÐèÒªÓÃSplitº¯Êý·Ö¸î¸÷ÏîÖµ
MultipleµÄSelect±íµ¥ÓëCheckBoxÀàËÆ£¬TextAreaµÄÖµ¿É°üº¬»»ÐÐ×Ö·û£¬ÓÃReplaceתΪ<br>£¬ÒÔÂú×ã¸ñʽÐèÒª
Session£º£¨Óû§È«¾Ö±äÁ¿£©
Session("SesName")£½value£º´æ´¢Session±äÁ¿Öµ£¬Ò²¿É¶ÁÈ¡¸ÃÖµ
Session("SesName")£½Empty£ºÅжÏSessionÖµÊÇ·ñ´æÔÚµÄÁ½ÖÖ·½·¨
IsEmpty(Session("SesName"))=True False£ºÅжÏSessionÖµÊÇ·ñ´æÔÚµÄÁ½ÖÖ·½·¨
Session.TimeOut=num£ºÉèÖÃSession±äÁ¿µÄ´æÔÚʱЧ£¬µ¥Î»·ÖÖÓ
Session.Abandon£ºÇå³ýËùÓÐSession±äÁ¿Öµ
Session.SessionID£ºSession±äÁ¿µÄIDÐòÁкţ¬Ö»¶Á
Application£º£¨Ó¦ÓóÌÐòÈ«¾Ö±äÁ¿£©
Application("AppName")£½value£º´æ´¢Application±äÁ¿Öµ£¬Ò²¿É¶ÁÈ¡¸ÃÖµ
Application("AppName")£½Empty£ºÅжÏApplicationÖµÊÇ·ñ´æÔÚµÄÁ½ÖÖ·½·¨
IsEmpty(Application("AppName"))=True False£ºÅжÏApplicationÖµÊÇ·ñ´æÔÚµÄÁ½ÖÖ·½·¨
Application.Lock£ºApplication±äÁ¿ÖµËø¶¨£¬·Àֹͬʱ¸ü¸Ä±äÁ¿Öµ
Application.UnLock£ºApplication±äÁ¿Öµ½âËø£¬ÔÊÐí¸ü¸Ä±äÁ¿Öµ
×¢£ºSessionÓëApplication±äÁ¿¶¼¿ÉÒÔÓÃÀ´´æ´¢Êý×éºÍϵͳ¶ÔÏó£¬ÒýÓ÷½·¨ÊDZäÁ¿ÃûÏ൱ÓÚÊý×éÃû¶øÒÑ£¬
µ«²»ÄÜÖ±½Ó¸Ä±äÆäÖµ£¬ÐèÒª½èÖúÁÙʱÊý×éÐÞ¸ÄÖµºó£¬ÔÙ¸³¸øSessionÓëApplication±äÁ¿
Global.asaÎļþµÄ½á¹¹£º<% @language="VBscript"%>
<% Sub Application_OnStart ...End Sub
Sub Application_OnEnd ... End Sub
Sub Session_OnStart ...End Sub
Sub Session_OnEnd ... End Sub%>
Server:
Server.MapPath("FileUrl")£ºÓ³ÉäÎļþÃûµÄ·þÎñÆ÷Õ¾µã¾ø¶ÔµØÖ·£¬Path=Server.MapPath(./)¿ÉÒԵõ½ÐéÄâĿ¼¸ù·¾¶
Server.HtmlEncode("string")£º×ª»»Îª¿ÉÒÔÖ±½ÓÏÔʾ´øHtml¸ñʽµÄ×Ö·û´®£¬È磺<,>µÈ
Server.URLEncode( "string")£º×ª»»Îªä¯ÀÀÆ÷µØÖ·±àÂë
set Var£½Server.CreatObject("ObjName")£º´´½¨¶ÔÏó±äÁ¿
Server.ScriptTimeout = NumSeconds£ºASP³ÌÐòÒ³ÃæÖ´ÐÐʱÏÞ£¬ÒÔÃëΪµ¥Î»
Cookies: ´æ´¢ÔÚÓû§±¾»úµÄÁÙʱ±äÁ¿£¬Ã¿¸öCookieµÄ×î´ó×Ö½Ú4KB£¬×î¶à¿ÉÒÔÓÐ300¸öCookie 1.2MB
Response.cookies("StrCookieName")£½value£º´æ´¢Cookie±äÁ¿Öµ£¬Ò²¿É¶ÁÈ¡¸ÃÖµ
Response.cookies("StrCookieName")£½""£ºÅжÏÊÇ·ñΪ¿Õ
Response.cookies("StrCookieName").Expires=Date£º±äÁ¿ÓÐЧÆÚ£¬ÒÔÌìΪµ¥Î»£¬Ð¡ÓÚµ±Ç°Ê±¼äÁ¢¼´Ê§Ð§
Response.Cookies(Cookie[(key).Attribute])£º±ê×¼Óï·¨
ObjectContext ¿ØÖÆASPµÄÊÂÎñ´¦Àí
ObjectContext.OnTransactionAbort£ºÓÉ·ÅÆúµÄÊÂÎñ´¦Àíʼþ¼¤·¢£¬Ôڽű¾Íê³É´¦Àíºó·¢Éú
ObjectContext.OnTransactionCommit£ºÓɳɹ¦µÄÊÂÎñ´¦Àíʼþ¼¤·¢£¬Ôڽű¾Íê³É´¦Àíºó·¢Éú
ObjectContext.SetAbort£ºÏÔʽµÄ·ÅÆúÒ»´ÎÊÂÎñ´¦Àí
ObjectContext.SetComplete£º¸²¸ÇÇ°ÃæÈκε÷ÓÃObjectContext.SetAbort·½·¨µÄµ÷ÓÃ
Msgbox "string"/StrName£ºVBscriptÌáʾ¿ò
±íµ¥µÄOnsubmitʼþ£ºÔÚͬһҳÃæдÈë Function FormName_onsubmit()..FormName_onsubmit£½True/False..end Function£¬
Ò³Ãæ»áÔÚÌύǰÏÈÖ´ÐÐÓï¾ä£¬²¢¸ù¾Ý·µ»ØÖµÅжÏÊÇ·ñÍê³ÉÌá½»ÈÎÎñ¡£
Êý¾Ý¿âÁ¬½Ó×Ö·û´®¾ÙÀý£º
Access2000£º
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbase\liuyan.mdb")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbase\liuyan.mdb")&";Password=admin"
Recordset.Open "Êý¾Ý±íÃû", conn, 2, 2
SqlServer2000£º
conn.Open "Provider=SQLOLEDB.1;User ID=sa;Password=admin;Initial Catalog=pubs;Data Source=server\garlmrm"
conn.Open "provider=SQLOLEDB;data source=hyserver;uid=sa;pwd=;database=pubs"
Recordset.Open StrSQL, conn, 2, 2
Dbase£º(?)
conn Open "Driver={Microsoft dBase Driver};SourceType=DB;SourceDB=" & Server.MapPath( "Ŀ¼Ãû" )
Recordset.Open StrSQL, conn, 2, 2
FoxBase£º
conn Open "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" & Server.MapPath( "Ŀ¼Ãû" )
Recordset.Open DBFÎļþÃû»òSelectÓï¾ä, conn, 2, 2
conn Open "Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=" & Server.MapPath( "DBCÊý¾Ý¿âÎļþÃû" )
Recordset.Open DBFÎļþÃû»òSelectÓï¾ä, conn, 2, 2
Excel£º
conn Open "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & Server.MapPath( "XLSÎļþÃû" )
Recordset.Open "Select * From ["&sheet&"$]",conn,2,2
×¢£ºÊ¹ÓÃDBF¡¢DBC¡¢ExcelÊý¾Ý¿â£¬ÏÂÃ漸µãҪעÒ⣺ExcelÊý¾Ý¿âÖ»ÄܶÁÈ¡¡¢Ôö¼Ó¼Ç¼¡¢Ð޸ļǼ£¬µ«²»ÄÜɾ³ý¼Ç¼£»
DBF¡¢DBC¿ÉÒÔ¶ÁÈ¡¼Ç¼¡¢Ôö¼Ó¼Ç¼¡¢É¾³ý¼Ç¼¡¢Ð޸ļǼ£¬µ«ÊÇÔÚÔö¼Ó¼Ç¼ʱ£¬ÈκÎÒ»¸ö×Ö¶ÎÖµ¶¼²»ÄÜΪ¿Õ£¬ÓÉ´Ë
¿É¿´³ö¾ÖÏÞÐԺܴó£¬ËùÒÔ¾¡¿ÉÄܵØÓÃMDB»òSQLÊý¾Ý¿â¡£
……