Jaxcent for .NET

Programming Overview

The JaxcentPage class

A class always used in Jaxcent programming is Jaxcent.Web.JaxcentPage.

Objects of this class (or classes that inherit it) are used to manage interactions with the browser page. Each instance of JaxcentPage (or an inherited class) manages the Jaxcent connection to one browser page. This is similar to .ASPX code-behind object instances, but unlike .ASPX, the JaxcentPage instance is not discarded after each round trip between the browser and the server. Instead, the instance stays in use as long as the visitor stays on that page. The lifetime of a JaxcentPage object could involve several user interactions.

Jaxcent can be used with

If you are using Jaxcent to assist with an ASPX page, you will need to declare and instantiate a JaxcentPage object in the .ASPX page's code-behind, and add Jaxcent event-handlers and Jaxcent method calls there.

If you are using Jaxcent to work with a raw HTML page, you will need to define a class that inherits JaxcentPage, and put all your Jaxcent programming in that class.

The HTML elements

The browser pages (whether ASPX or HTML) have various HTML elements in them, such as paragraphs defined by the <P> tag, tables defined by <TABLE> tag, input buttons defined by <INPUT TYPE="BUTTON"> tag, and so on.

Corresponding to all of these types of HTML elements, there are Jaxcent classes, such as Jaxcent.Web.Html.JaxcentPara for <P>, Jaxcent.Web.Html.JaxcentTable for <TABLE>:, Jaxcent.Web.Html.JaxcentInputButton for <INPUT TYPE="BUTTON"> etc. In addition, there is a Jaxcent.Web.Html.JaxcentGenericHtmlElement that can be used for any unusual tags not already covered.

For each HTML element on the page that the programmer is interested in, an object of the corresponding Jaxcent class needs to be instantiated. This object has to be told which of the possibly multiple HTML elements on the page it needs to manage. This can be conveniently done with an "ID" (though there are other mechanisms as well.) E.g., the para of interest is marked with an id "MyPara"

  <P id="MyPara">Text of the para</P>
and the JaxcentPara is instantiated with this id, e.g.
    JaxcentPara para = new JaxcentPara( jaxcentPage, "MyPara" );  // C#

    Dim para As New JaxcentPara( jaxcentPage, "MyPara" )          ' VB

The Jaxcent programmer can also create new HTML elements and add them to the page.

Interacting with HTML elements

The HTML elements can be directly controlled by the programmer, e.g.
    para.InnerText = "New Textual Content"
will change the existing contents of the para. The styles and other attributes can also be changed similarly.

Events

Jaxcent programming is event driven. Some actions may be taken in a constructor, but commonly most actions occur in response to an event.

Varius events can be received from the "para" in the example above, e.g. OnClick which is fired when the user clicks anywhere in the para. (Though from a UI point of view, it is common to react upon clicks on buttons, or HREF links, rather than upon clicks on paragraphs.)

To receive events from a JaxcentPara or a JaxcentInputButton or JaxcentStdButton (which corresponds to <BUTTON> tags), simply add a handler for the appropriate event.

There are often multiple versions of OnClick available, and the data transfer depends on the actual event(s) which has been provided a handler. Instead of providing a handler for OnClick on a button, you can choose to provide a handler for the OnClickWithPageData event - in which case Jaxcent will also deliver to you the current contents of any user-input form elements (such as TEXT, CHECKBOX, TEXTAREA) along with the click event. This reduces the number of client-server round-trips, and improves responsiveness and performance.

The JaxcentPage itself has some events. The OnPageLoaded event can be used to initiate actions that need to be taken after the page has loaded. Until the page has been loaded, the Jaxcent sessions are not available. Also, until the page has been loaded, the input elements such as TEXT, CHECKBOX etc cannot be actively queried by the program. Such actions can be handled in an OnPageLoaded handler.

Note: Because Visual Studio is not Jaxcent-aware, event bodies cannot be generated simply by double-clicking on a form element. However, adding events directly is very simple in Visual Studio. In C#, this is done by typing the object name, a dot, the event name, the += characters, and then two TABs. E.g.

    button.OnClick += <TAB> <TAB>
will add an OnClick event handler to "button", and will generate the handler function body as well.

In Visual Basic, the "CODE" view can be used to select "button" on the left, and "OnClick" on the right, which will generate the event handler.

Other Features

This WinForms style of programming allows Jaxcent to include easy-to-use solutions for various common web-programming paradigms.

For instance, JaxcentTable class provides various commonly used "Grid" features, e.g. updating from a DataTable, even/odd row styling, inserting row-specific string.Format'ted checkboxes, links, buttons etc in each row, and table cell editing.

The JaxcentUploadForm class provides convenient methods for uploading files. JaxcentImage class provides methods for setting any image in the <IMG> tag beyond the normal setting of the "SRC" to an existing image file such as JPEG or PNG - in Jaxcent the image being set could very easily be bytes read dynamically from a .JPEG file, or could be something that was created using System.Drawing or some other image-creation API on the fly.

Jaxcent sessions are also different from standard Web sessions. Instead of making a guess on a timeout, e.g. "the user has not clicked on anything for 20 minutes, we can delete the user's session", Jaxcent sessions provide fine-grained control over the timeout. By default Jaxcent session timeouts do not start as long as the user stays on a page with that session. (The programmer can manually delete the session after a given time interval for security or other reasons.) Because the timeout doesn't start until the user leaves the session pages, Jaxcent timeouts can be smaller, defaulting to 5 minutes. This minimizes the number of unused sessions residing on the server, further improving server performance.

Furthermore, Jaxcent's design also allows Jaxcent to offer full automation of the common web-paradigm of collection form input data into session. If enabled, Jaxcent will collect form input data at page unloading, and will automatically save it in the session.

Getting Started

In addition to a "Getting Started" topic for C# and for VB, there are also various Jaxcent samples provided that can help in getting started with Jaxcent.