Jaxcent for .NET

Getting Started with Visual Basic

In this section, an overview is provided by actual coding examples. It's recommended that a few minutes be spent actually doing this - however, for users who want to skip over it, the Jaxcent installation includes pre-built project samples named "HelloWorldAspx" and "HelloWorldHtml" that can be reviewed if desired.

Adding Jaxcent to a project

The installer adds a "Jaxcent" item into the standard Developer Studio "Add New Item" menu, in the "My Templates" section, as shown below.

This item can be used to insert the required Jaxcent files to a project. Adding a new Jaxcent item will

(Note that the name you specify to the "Add New Item" will be ignored.)

Getting stated with Jaxcent using a .aspx page

Create a Visual Basic ASP.NET Web Application project, and use the "Add New Item" menu to add Jaxcent to it. Use View-Code to access Default.aspx.vb, and add the following:

Imports Jaxcent.Web
Imports Jaxcent.Web.Html

at the top and then inside the _Default class, add the declaration

    Public jaxcentPage As New JaxcentPage

In the .aspx HTML markup, add the following inside the <head> section

    <script type="text/javascript" src="JaxcentDotNet23.js?jaxcentid=<%= jaxcentPage.JaxcentConnectionID %>"></script>

This connects the HTML client page to this particular instance of the JaxcentPage object on the server. Note that jaxcentPage needs to be declared public so it can be accessed from the markup.

  Jaxcent coding for the .aspx file

Add the following to the Default.aspx markup

    <asp:Button ID="HelloButton" Text="Hello" runat="server"/>

inside the <form> created by Visual Studio. Also add

    <p id="MessageText"></p>

to the markup. This can be inside the form or outside.

In the code-behind Default.aspx.vb file, add declarations for a JaxcentInputButton and JaxcentPara objects in the class.

    WithEvents button As New JaxcentInputButton(jaxcentPage, "HelloButton")
    Dim message As New JaxcentPara(jaxcentPage, "MessageText")

Here, we are telling Jaxcent that the object button is to be connected to the HTML INPUT button with ID "HelloButton" on the page, and that the message object is to be connected to the P with ID "MessageText".

Note that "button" is declared to handle events.

Now add an event handler to button's OnClick event, by selecting the "button" on the left side in the "Code" view, and the "OnClick" event on the right side. Then modify the framework generated by Visual Studio to add some actions to the event handler.

    Private Sub button_OnClick(ByVal src As Jaxcent.Web.JaxcentObject) Handles button.OnClick
        message.InnerText = "You clicked hello at " + DateTime.Now.ToString()
        jaxcentPage.ShowMessageDialog("Hello, World")
    End Sub

You can now run the project, and click on the Hello button.

This shows some basic capabilities of Jaxcent - responding to events, changing HTML on the page, and showing a message-box to the user.

Getting stated with Jaxcent using a .html page

It is not necessary to use .aspx files, Jaxcent can also be used with .htm and .html files.

Create a VB Web Application project, and use the "Add New Item" menu to add Jaxcent to it. Then delete the Default.aspx from the project, and add an HTML page named Default.htm instead.

Add the following inside the <head> section in the Default.htm page

    <script type="text/javascript" src="JaxcentDotNet23.js"></script>

Since there is no existing code-behind for the page, we need to make a new class for it. Add a new class, let's say a class named HelloWorldPage. Add the Jaxcent "Imports" statements in the HelloWorldPage.vb file

Imports Jaxcent.Web
Imports Jaxcent.Web.Html

and make the class inherit from JaxcentPage

Public Class HelloWorldPage
    Inherits JaxcentPage

In the HTML markup, add a FORM with an input button with ID "HelloButton" in it, and a para (P) with ID "MessageText". In the code, add declarations for a JaxcentInputButton and JaxcentPara objects in the class.

    Private WithEvents button As JaxcentInputButton
    Private message As JaxcentPara

Then add a "New()" constructor and in that constructor add the following code:

    Sub New()
        button = New JaxcentInputButton(Me, "HelloButton")
        message = New JaxcentPara(Me, "MessageText")
    End Sub

Just as with the .aspx page, also add the OnClick event handler for the button.

  Connecting HTML to the handler Class

We now have a class HelloWorldPage that's ready to handle the Default.htm page. But we need to tell Jaxcent that HelloWorldPage is connected to Default.htm.

This can be done via the "Global" class. Use "Add New Item" to add a "Global" class to the application. Then in the Global.asax.vb (code) file, add

Imports Jaxcent.Framework

and in the Application_Start method, add

        JaxcentFramework.GetInstance().AddURL("/default.htm", GetType(HelloWorldPage))
        JaxcentFramework.GetInstance().AddURL("/", GetType(HelloWorldPage))

This code is telling the Jaxcent framework that the URLs /default.htm and / (which loads default.htm) both should be handled by the HelloWorldPage class.

Now when the / or /default.html URLs are encountered, Jaxcent will instantiate a HelloWorldPage object, and connect that object to the browser page.

The above provides an introduction to the basics of Jaxcent. Automatic Data Collection that shows this feature.

Continue to Visual Basic Sample Projects