Classic ASP Framework.

In short, CLASP is an event driven Framework developed in VBScript for the development of Classic ASP Web applications.
Now, you may ask yourself, why should I consider CLASP when there is ASP.NET out there?. Well, I started to work on this framework to target people that:

  • Need to maintain/extend current ASP Applications that will not be migrated over to .NET in the near future.
  • Still need to or like to work in Classic ASP.
  • Want to distribute their web applications as a stand alone executable (using a Web site compiler such as Intorel Active Site Compiler - http://www.intorel.com/ )
  • All the above while making sure that your code will be easily ported to ASP.NET.

    And why should I use CLASP and not do it my own way?
  • It simplifies your coding and makes it very portable to ASP.NET.
  • Provides you with a rich event driven environment that resembles ASP.NET and Visual Basic Windows applications.
  • Supports ViewState, client side libraries and other features.
  • It has a large list of web controls.
  • It is FAST!!!
  • It is FREE
  • It is a white box, nothing to hide here!, you can modify the code to suit your needs.


    Below is a high-level diagram of the CLASP Framework.

    The CLASP Framework is very simple and almost everything is handled automatically. To better explain the Diagram above, I will describe what each of the "boxes" is for.

    CLASP PostBackHandler: This is a fancy name for a very simple JavaScript function. The function is included with in a js file references by WebControl.asp and has the following "signature" clasp.form.doPostBack(action,object,instance,xmsg,frmaction,frameName). All CLASP WebControls make use of this function one way or another trigger server side evennts to be consumed by the framework. These (the scripts) "PostBack Handlers" can be access by using the GetEventScript functions of the Page object (plural because they are a few versions of this function to handle different scenarios such as posting to a new window) . 

    For instance, if you want to submit a event from the browser whose target is the Page and pass the value 1 you could do this clasp.form.doPostBack("TheEvent","Page",1); This will make CLASP to submit the page and invoke Page_TheEvent(e).  "e" is the Event object, which you can examine and get data from, such as the value "1", which will be one of the parameters.

    The WebControls normally make use of the Page.GetEventScript functions. For instance, buttons always get an event scripts this way: Page.GetEventScript("onclick",Me,"OnClick","",""), this will translate to (suppose the button name is cmdSave) : onclick = 'doPostBack("OnClick","cmdSave")' . This will cause the CLASP Framework to submit the page and in the server side look for the target of the event, in this case a WebControl with name cmdSave and route the event to the instance, which in turn will evaluate and, in the case of a button, it will simple call cmdSave_OnClick . This is how, from the Client (WebBrowser) an event gets routed the appropriate handler in the Server. There are more complex scenarios such as when you create complex user controls (ones that make use or are composed of other webcontrols). The Framework supports even bubbling, which is useful when building complex controls.

    CLASP Response: This simple means that you must use Page.OpenForm and Page.CloseForm to enclose your form. Why?, well, these includes will render the html hidden form fields that are used by the CLASP PostBackHandler, including viewstate, if using client side viewstate.

    CLASP Request: Another fancy name.This simple means that all postbacks must be done by using the CLASP PostBackHandler and on a page that was rendered using a CLASP Response, which means that all CLASP hidden fields must be included.

    CLASP Framework: This is a generic term used to name the Framework and all  corresponding functionality. At a very high level, you have the Page object, which orchestrates everything. When you submit a CLASP Request, the framework automatically creates an instance of the cPage object conveniently named "Page". When this instance is initialized it checks that all CLASP form fields are included and determines the PostBack mode (IsPostBack = True/False and/or IsRedirectedPostBack = True/False). Now, depending on the mode, it will load the viewstate and perform other functions. The Page object also includes a function named Page.Execute, which will do the magic (load viewstate, transfer it to the WebControls, route events, etc). Take a look at the Page object for detailed information.

    CLASP Controler: This is a special and optional part of the Framework. This class provides the developer with a consistant way of using the CLASP Framework. The main goal is to allow you to write page templates (with support for role-based security). How, well, by simply adding more funtionality on top of CLASP. This Class adds the following events: Page_Configure, Page_RenderHeaderTag, Page_RenderHeader, Page_RenderForm, Page_RenderFooter. It also includes global handlers for authentication and authorization to be used with the CurrentUser object.

    Form more information go to PageContoller.CLASP provides a template of the PageController, which you should override (copy/paste and use your own customized version)

    CLASP Server Controls: What is a server control?, it is a Class that contains and exposes a WebControl object named "Control". By including an instanciated object of type WebControl your class will register itself with CLASP (well, the WebControl will do it). By doing this the Server Control will participate on internal CLASP events, such as WriteProperties and ReadProperties, used to persist/restore information to/from the viewstate. The framework has a comprenhensice list of Server Controls, from simple textboxes and checkbox lists  to data grids, data repeaters, etc.  To understand better how a WebControl works click here.

    CLASP Page Event Handlers: The framework is 100% event driven, and a succesfull implementation of CLASP should only have code within events (the HTML part could have some in-line code just to render the controls). The "Page Event Handlers" are the core handlers such as Page_Init, Page_Controls_Init, Page_Load which you tipically would include in your pages.

    Page-Specific Functions: This are supporting functions specific to the page, such as functions to load a record, do some validation or calculations.




    Below is a diagram with the sequence of events. The CLASP Framework events are in green. If you are using the PageController, then the sequence the PageController dictates the new sequence.