Controlling ASP from VB component

Results 1 to 3 of 3

Thread: Controlling ASP from VB component

  1. #1
    Tim W. Guest

    Default Controlling ASP from VB component

    Can someone point me in the right direction on how to control ASP from within a component? I am wanting to do response.writes inside a component instead of returning a string to the ASP page.

  2. #2 Guest

    Default RE: Controlling ASP from VB component

    To create a COM object that is tightly intergrated with ASP (Active Server Component):<BR><BR>1. Create a VB ActiveX DLL project<BR>2. Reference the Microsoft Active Server Pages Object Library<BR>3. In the declarations area of your class, create the following private variables:<BR><BR>Private oScriptingContext As ScriptingContext<BR>Private oApplication As Application<BR>Private oRequest As Request<BR><BR>etc., etc.<BR><BR><BR>4. You need to create two public subs, OnStartPage and OnEndPage. These two interfaces are called by ASP automatically if they exist when a component is created at the beginning of an ASP page and when the object goes out of scope. Keep in mind, you don&#039t need to have these events if you plan to have larger than page scope for your component.<BR><BR>E.g.<BR><BR>Public Sub OnStartPage(ScriptingContext As ScriptingContext)<BR><BR> &#039 This sub is where you get pointers to the ASP objects<BR><BR> Set oScriptingContext=ScriptingContext<BR> Set oApplication=oScriptingContext.Application<BR> Set oRequest=oScriptingContext.Request<BR> Set oResponse=oScriptingContext.Response<BR> Set oServer=oScriptingContext.Server<BR> Set oSession=oScriptingContext.Session<BR><BR>End Sub<BR><BR>Public Sub OnEndPage()<BR><BR> &#039 This sub is where all the cleanup is done <BR><BR> Set oScriptingContext=Nothing<BR> Set oApplication=Nothing<BR> etc., etc.<BR><BR>End Sub<BR><BR>5. Now, in your public functions, you have total access to the ASP objects ... you could ...<BR><BR>Public Function Hello() As Boolean<BR><BR> oResponse.Write oSession.Timeout<BR> oResponse.Expires=-1441<BR> oResponse.End<BR> etc., etc.<BR> Hello=True<BR><BR>End Function

  3. #3 Guest

    Default RE: Controlling ASP from VB component

    Let me also add that if you don&#039t have those events, you could get pointers to the ASP objects in the Initialize event of your class ... and cleanup in the terminate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts