The three-level entry and proficient series of ASP components

zhaozj2021-02-16  140

Sense is more than comparison

Look

Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM and the class name is modified to FZ3 reference "Microsoft Active Server Pages Object" object library. Create two component events: OnStartPage and OneundPage Create a reference to the class ScriptingContent in the event onstartpage. Instantiated class scriptingcontent.

?

code show as below:

Option expedition

?

'Statement of the object

DIM MyResponse as response

DIM MyRequest as Request

DIM MyApplication AS Application

DIM MyServer As Server

DIM MySession as session

?

??? 'When the component is created, it will trigger this event.

Public Sub onstartPage (MyScriptingContent as scriptingcontext)

???? 'Installation of objects

???? set myresponse = myscriptingContent.response

???? set myRequest = myscriptingContent.request

???? set myserver = myscriptingcontent.server

???? set myapplication = myscriptingContent.Application

???? set myations = myscriptingContent.Session

End Sub

?

??? 'When the component is destroyed, it triggers this event.

Public Sub OneendPage ()

???? 'destroyed object

???? set myresponse = Nothing

???? set myRequest = Nothing

???? set myServer = Nothing

???? set myapplication = Nothing

???? set mysession = Nothing

End Sub

?

'It can be seen that put it in the previous ASP to VB, the way is the same.

'Get all SESSION variables and values

Public Sub ShowSession ()

'You can set up for a timeout 20 minutes

??? mysession.timeout = 20

??? DIM MyItem

??? 'get all the session

??? for each myitem in mysession.contents

??????? myresponse.write myitem & ":" & mysession.contents (myitem)

??????? myresponse.write ""

??? next

End Sub

?

test

Open Visual InterDev6.0 to generate an ASP file

<% @ Language = VBScript%>

<%

DIM OBJ

Set obj = server.createObject ("fcom.fz3")

Session ("Name") = "Tornado"

Session ("age" = 26

Session ("Special") = "Components"

Obj.showsession ()

%>

?

Configure a virtual directory, perform this ASP file in IE, you can see

Name: Tornado AGE: 26 Specific: Components?

The usage of session tells here. Session other usage is similar.

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

New Post(0)