ASP experience talk

xiaoxiao2021-03-06  99

ASP experience talks, ASP's scripting language

VBS CRIPT is an ASP scripting language because the ASP script is executed on the server side, so only the server side supports VBS CRIPT. VBS CRIPT is a subset of Visual Basic, although the number of built-in functions that can be used, but also makes him very small, thereby improving portability. The important differences between them are: variable types and scope of action; Use some built-in functions; add some functions and objects; how to process errors; ways to make the wrong debugging.

  Eg: 1 Code Convention: Sub-type Prefix Sample Boolean   Brou BLNFOUND BYT BYTRASTERDATA DATE BYT BYTRASTERDATA DATE (TIME) DTM Double       SNG SNG SNG STRING  STR

2 Variables:                            Length can not exceed 255 characters;   must be unique within the declared scope.

 static arrays and dynamic arrays:  For Example: Dim My_Array (10)  For Example: Dim My_Array ()  ReDim My_Array (10)

3 Procedures and functions:   process: for example:                                                                                                                                             Function: for es:                                                                                                    

  data type: Variant is the only data type of VBS CRIPT, 13 seed types: EMPTY, NULL, BOOLEAN, BYTE, INTEGER, CURRENCY, Long, Single, Double, Date (Time), String, Object, Error

5 constant:                                                                             

(Ii) VBS CRIPT's basic syntax: 1 operation:                                                 = not equal to <> less than <= Not less than> = Object reference comparison IS  Non NOT and AND AND or OR  x 等 EQV implicit IMP2 cycle statement:             LOOP When the condition is true to end cycle     WEND When the condition is true,   NEXT specifies the number of cycles, repeats the statement using the counter   in Each ... Next ... Repeat each element in each item in the collection

3 Conditional statement:              

4 Object:  Label Object: Dictionary Object: For Example: Dim diTom Set diTom = CreateObject ( "s cripting.Dictionary") diTom.add "name", "Tom Martiner" DITOM.ADD "Address", "2223 Road"

   = DITOM.ITEM ("name")

ERR object:                                                                          

                    

 VBS Cript function: 1 Mathematical function:   Anti-orthogonal cut ATN (NUM) Cosine COS (NUM) Sinusoidal SIN (NUM) Tan (NUM)   Absolute ABS (NUM) Natural log (NUM) Random number RND () symbol SGN (NUM)   Square root SQR (NUM) with E a bottom index exp (Num)

2 Format Transformation Function cbool (EXP) Transformation into Logical CCYTE (Exp) Transformation into single-by-zyntheal   CDATE (EXP) Transformation into Date-type CDBL (EXP) Transformation into Double-Bander TextR (EXP) Transformation Transformation into an integer   Cint (EXP) transformation into long integer   CSNG (Exp) transformation into single-precision   CSTR (Exp) transformation into string type         Encord character                                                                                      8 BaoVal (EXP) transforming into a number

3 String Operation Functions:    C (S) INSTR (S1, S2) LTRIM (S)                                       RTRIM (s) STRComp (S1, S2) TRING (LEN, CHAR) TRIM (s) ucase (s)

4 Time Date Functions:  Date () Time () Now ()                                                                                                                                           Month (Date) Minute (Time) Day (Date) Second (Time) WeekDay (Date) 5 variant subtypes: IsArray (var) IsDate (var) IsEmpty (var) IsNull (var) IsNumber (var) IsObject (var) Vartype (var)

Second, ASP basic knowledge

The ASP file is a text file, which is the same as ASP. A ASP file mainly following three parts: 1 HTML tag                      <%> This is distinguished by server-side ASP scripts and other characters. % @ Language = VBS cript%>                                                                                         s cripe> Tag language It will be performed immediately (when the web page is loaded)                                                                                                                                                                                                      ) 'Separate the QNAME string, then assign a array                                                         next  response.write "


"  %> 6 dynamically generated server-side script:  For Example:   <%  S = "Sub Hi" & vbCrLf  S = S & "response "hi" "& vbcrlf                                                                                

(Ii) Use SSI (Server-Side Include)  1 function: # config Specifies the format used by the error message / date and file size to return to the browser                      Application or a shell command and insert the output into the HTML page. # FlastMod Insert the file's modification date into the HTML page   # fsize Insert the file size into the HTML page # include in the HTML or ASP page contains files 2 #include command (executed when the server is formatted page)   |    For Example <- - # include virture / file = path file!>:!   <- # include file = "Sunday .html "-> 3 #EXEC instructions can be running programs can be: CGI programs, ASP applications, isapi applications. The path is the complete virtual path or URL   The method of passing parameters to the application is here. The application name is followed by a question mark and a list of parameters connected by the plus sign, which can only be used in the HTML page, cannot be used in the ASP page.   Parameter CGI is used to run an application, such as CGI script / asp Or ISAPI Application  Parameter CMD Used to Run the shell command                                                            Format of error message / date / file size, etc. Errmsg parameters:                                                                                 % A a week in a week, such as: Monday                                                                                                05/06/91 12:51:32% D a day (01 ~ 31)% h 24 hours format (00 ~ 23)  % i 12 hours format (01 ~ 12)% J a day in one year (001 ~ 366 )% M month (01 ~ 12)  % M minutes (00 ~ 59)             % s seconds (00 ~ 59)% u one year A week, Sunday, as a week (00 ~ 51)   One day in the week, Sunday is the first day (0 ~ 6)% w a week in a year, Monday begins as a week (00 ~ 51)% x local dates, such as: 05/06/91                                                                                                                                  Year, such as: 1996% z,% z time zone full name or abbreviation, if you don't know the time zone, there is no character. %% percent sign                     '

To kilobytes 6 .inc file include file  three ASP objects (Request, Response, Server, Application, Session)  five basic objects: Request Object Response Object Server Object Application Object Session Object                                                                                 When users use GET methods to transfer data when users use GET methods in Form The data submitted by the user is attached to the query string (QueryString), which is submitted to the server-side specified file. The role of the queryString collection is to read the data submitted by the user from the query string.   can not use form as The input of the browser, can directly use the statement:                                                                     the input tools):  Browser:  

 please input all the cities you have lived:       =" city ">                                                                                                                                / form>             (Hometown.asp)                                                           When the browser side is submitted to the server When the form element can be retrieved as a member of the Form collection, the data transmitted by this approach is much more than queryString, so this method is commonly used.   Note: Request.form.count indicates the number of submitted in the form                     .Form ("hobby"). Count indicates the number of form fields submitted by the same name ("hobby")  

             

  ServerVariable   Used to provide HTTP header information to pass along with HTTP requests, the browser's request and server response contains Headers. Using the format Request.ServerVariable ("key")                                                                                                                                                            Content_length: The length of the text submitted by the client                                                            Revision, format: CGI / revision                                                      Query_String: Inquiry information. Just? The future part                                    r    HEAD et al.                                                                                                                                                 SERVER_PORT: port number  data requests used SERVER_PORT_SECURE:. port if port security data request is used to protect the return to "1" (the character is not a number)  SERVER_PROTOCOL: requests for information and protocol revisions                                                                                   h                                                                         Operating system                                                           The computer resolution of the machine where the browser is located

 (ii) Response:   property: Buffer, Cookies, ContentType, Expires, ExpiresAbsolute,  Status, IsClientConnected, CacheControl   method: Write, Redirect, End, Flush, Cookies, BinaryWrite, AddHeader  AppendToLog   role: to Browser Output Text / Data and Cookies and Controls Each Stage during Transmit Web Pages       Do you need a buffer when the page output is required, and set the statement to the forefront of the entire file.   2 ContentYPE properties:   "text / html" "image / gif" "Application / Msword" "Text / RTF"

  3 Expires attributes:   Time length for setting the browser buffer (minute)   Set EXPIRES = 0 will require each request to refresh the page, because Response will expire

                   <% response.expiresabsolute = # OCT 1,1999 00:00:00 #%> October 1, 1999 is deadline

  5 Status property: s s state of delivery server HTTP Response  1xx:.  2xx:   3xx: expressed as 301 have been transferred to other home address  4xx: 404 as represented by the requested page is not Existence                                                             

 6 IsClientConnected attributes:  For Example:   <%  dim i  i = 1  while i = 1  response.write ( "hello world")  if not response.isclientconnected then response .end                 

 7 CacheControl attributes:  response.cachecontrol = "public" will allow the proxy server to put as ASP cache.

     When "%>" is output, use "% />" essential character instead.

  <%  fontcolor = "green"  response.write "> ou are well "  %>   be:   <%  fontcolor = "green"  response.write " you are well  %>  9 Clear method:   If the Response Buffer property is set to True, this method clears all cache area pages.

  10 Flush method:   When the flush method is called, the cached server response output information will be sent to the customer. Like the CLEAR method, if there is no in advance, response.buffer = true will have an error.

                                Used to inform Active Server immediately stop processing ASP files immediately, if buffer = true, send the cached content to the customer, then clear the buffer, so if you want to cancel the user Output, you can clear the buffer and use this method.

            Use to write binary information to HTTP output, usually use to use a custom client application that needs special non-character information. There is a special HTTP header to send to the client application.

  AppendLog method:   Add a entry for this special requirement at the end of the web server log.   Character maximum length 80, can not be divided with comma.

  15 cookies collection:                                                                                                                       Domain ") =" www.microsoft.com "                                                                                                             s       read  HasKeys ": Cookie dictionary If the requested Cookie is a having a plurality of keys, returns True, it is a read-only attribute   write Cookie:  response.cookies (" cookie name ") [ ( "key name-value") properties] = content (data) read-s s Cookie:.  request.cookies ( "cookie name") [( "key name-value") properties] = content (data)  Cookie. Dictionary:           s cripttimeout: CreateObject, mappath, urlecode, htmlecode   Creating a COM object and s cripting component.               Specify a script delay period (second )  2 HTMLEcode method:  3 URLEcode method: in accordance with the format of the output  URL 4 MapPath method: return path or relative physical path  5 CreateObject method to a specific file: ㈣ Application:   properties: N s   method: Lock, UNLOCK   Run: For sharing information between multiple users of the same application                                                                                                                                      Application ("Attribute Name") = Value                                                                                                                                               Application_OnEnd ()   ㈤ defined in global.asa file Session:   properties: SessionID, TimeOut   method: Abandon   effect: s holding the data for a single user is a visitor from 1 reach a The specific home page knows the time from the time, each visitors will get a session,

Closing the gap in the continuous  HTTP response 2 SessionID attributes: unique identifier of the current session, automatically assigned  3 TimeOut attributes: User Session time limit (min), 20  4 default custom properties:  Session ( "property name") = value  5 Session_OnStart ()  Session_OnEnd ()    6 Abandon method defined in the global.asa file:   eliminate the user's Session object and releases its possession resources ㈥global.asa: s configuration file:    Sub Application_OnStart ()  End Sub  Sub Application_OnEnd ()  End Sub  Sub Session_OnStart () nd Sub                                   

Fourth, ASP Database Connection  Use Active Data Object (ADO) to connect to the database.   Started using ado:   In ODBC Data Source Manager, select System DSN, "Add", ~~~~  2 Adovbs.inc file:  3 connection Object <- - #include virtual = "/ aspsamp / samples / adovbs.inc"!>:  connection: set con = Server.CreateObject ( "ADODB.Connection") con.Open "DSN = ; uid = ; pwd = "   [con.connectionstring = "DSN = ; uid = ; pwd = " con.open] CON.CLOSE 'Close the business:   method: Begintrans, CommitTrans, RollbackTrans,                                                                                                                               %                                                                                            "                                         >   Table border = 1>                            <%                               Coco = 0 to myRecordset.count-1%>                                              MoveNext          

转载请注明原文地址:https://www.9cbs.com/read-105213.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.048, SQL: 9