ASP Components Intermediate beginner and proficient series of five

Source: Internet
Author: User
Let's learn to look at the response object. In fact, we have been using the Write method of this object in previous tutorials.
Here we use the Response object to set cookies.
?
Open VB6 and create a new ActiveX DLL project. Project name modified to fcom, class name modified to FZ5
References the Microsoft Active Server Pages Object Library.
Create two component events: OnStartPage and OnEndPage
Creates a reference to the class Scriptingcontent in the event OnStartPage.
Instantiate class Scriptingcontent.
?
The code is as follows:
Option Explicit
' The Declaration of the object
Dim Myresponse as Response
Dim Myrequest as Request
Dim MyApplication as Application
Dim MyServer as Server
Dim MySession as session
?
??? ' Triggers this event when the component is created
Public Sub OnStartPage (myscriptingcontent as ScriptingContext)
???? ' To instantiate the object
???? Set Myresponse = Myscriptingcontent.response
???? Set myrequest = myscriptingcontent.request
???? Set MyServer = Myscriptingcontent.server
???? Set MyApplication = myscriptingcontent.application
???? Set mysession = myscriptingcontent.session
End Sub
?
??? ' Triggers this event when the component is destroyed
Public Sub OnEndPage ()
???? ' Destroy objects
???? Set Myresponse = Nothing
???? Set myrequest = Nothing
???? Set MyServer = Nothing
???? Set MyApplication = Nothing
???? Set mysession = Nothing
End Sub
?
' Set cookies from the page, the component gets
Public Sub GetCookie ()
??? Dim myitem
??? ' All information
??? For Each myitem in Myrequest.cookies
??????? Myresponse.write myitem & ":" & MyRequest.Cookies.Item (myitem)
??????? Myresponse.write "
"
??? Next
???
??? ' Single information
??? Myresponse.write "Where the user name is" & ":" & Myrequest.cookies ("username")
??? Myresponse.write "
"
??? Myresponse.write "in which the user age is &:" & Myrequest.cookies ("aged")
??? Myresponse.write "
"
End Sub
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.