Creating your first page "Hello World!"    Getting-started

ajaxed is page-driven which is defined by the AjaxedPage class. Others would say it's our page controller. Call it whatever you want :) The thing to remember here is that each of your pages will contain an instance of AjaxedPage. With that knowledge we can code our first page:

<!--#include virtual="/ajaxed/ajaxed.asp"-->
<%
set page = new AjaxedPage
page.draw()

sub main()
  str.write("Hello world!")
end sub
%>
Run this code — hello-world.asp

Ok, lets have a look what happend here. First we included the ajaxed library (include statement) and created an instance of AjaxedPage which is drawn afterwards - draw() method.

In order to make the draw work we need an entry point for our page. This entry point is a procedure called main. Our entry point contains only one line which prints out Hello world!. str.write() is the ajaxed version of response.write. Get used to it :) The thing to remember here is that the output of your main procedure will be surrounded with the page header and page footer.

Oh, you wanna see more. Here comes a more sophisticated example for everyone who wants to see more at this point:

<!--#include virtual="/ajaxed/ajaxed.asp"-->
<%
set page = new AjaxedPage
page.title = "A page title"
page.draw()

sub main()
  content()
end sub

sub content %>

  The page is located here:<br/>
  <%= page.getLocation("virtual", true) %>
  <br/><br/>

  The environment is: <%= lib.env %>
  <br/><br/>

  ajaxed version: <%= lib.version %>

<% end sub %>
Run this code — page.asp

Hmm, thats not really sophisticated I guess. However, I think you can figure it out by yourself what that code does. One thing to note here is the seperation of code and content. As you can see the example calls a content procedure within the main. The content is our view and the rest (main and the other procedures) is the page controller. The view consists mostly of markup thats why it is not surrounded with propellers whereas the rest of our code has propellers. Brings a bit of MVC feeling :)

Posted in Getting-started 5801 days ago

Version 2.1.1 Released4132 days ago