
Storing Classes in the "Session" Object
Hmm.
OK - small issue, no intellisense.
After a bit of research, remove the script section in the
<registration></registration> section that generates the typelibrary - it
works but kills the intellisense for some reason.
After that, you'll have intellisense in Interdev but you'll have to keep
each WSC in a seperate folder cos they (when you have more then one) all
generate the same name typelibrary (.tlb) file. 'scriptlet.tlb'.
Chris Barber.
OK - put the following files (in the attached zip) into a web project in
IIS.
You will need to register the WSC *once* only - any changes to it after that
are fine - it has no concept of binary compatibility as a scripted COM
component. However you will be able to see (open it in Notepad for example)
that it has a public interface and internal implementation in JScript and
VBScript.
When you register it (right-click and select Register if you have IE 5.5+
installed) you will see that it generates a tlb file (see the internal
script routine to do so).
When you've done that then run the DemoInit.asp page (it sets a couple of
properties of the WSC component) and then opens the DemoTest.asp page to
show you that the session persisted property still holds data. I have also
included a demo JScript function to show that you can mix and match script
engines.
It is possible to use these without registering them by using the
GetObject() call instead of CreateObject(). However, you won't get any
intellisense (in Interdev foe example).
You can also step into the script in Interdev debugging but it's not the
easiest thing to set-up. Pay careful attention to the debug="true" and
error="true" at the top of the WSC file - set these both to "false" ina
production environment to stop errors generating a dialogbox on the
webserver (not a happy occurrence).
Any questions, email me.
Also, see microsoft.public.scripting.scriptlets newsgroup.
Have fun.
Chris Barber.
Thanks. Yes, I do.
Quote:
> I believe that VBScript and JScript classes don't persist outside of the
> page that they are generated in - someone please correct me if I'm wrong.
> If you need to persist classes then I suggest you use WSC components and
> defined the properties and methods within that so that each property
stores
> itself in the session / application object and retrieves it as required.
> Let me know if you would like an example of this.
> My Opinion: WSC is the best thing since sliced bread - script based COM
> components that give intellisense in the Interdev development environment.
> Chris Barber.
> Does anyone know of explanations and exmples how to use vbscript (or
> jscript) classes and keep them in the "Session" or "Application" objects?