ajaxed v2.1 API Documentation
Info: You are browsing the API docs of a previous ajaxed version.Click here if you want the latest API docs (2.1.1)
<!--#include virtual="/ajaxed/ajaxed.asp"-->
<%
set page = new AjaxedPage
page.title = "my first ajaxed page"
page.draw()
sub main()
'the execution starts here
end sub
%>
<% sub pagePart_one() %>
<strong>some bold text</strong>
<% end sub
sub main() %>
<div id="container"></div>
<button onclick="ajaxed.callback('one', 'container')">load page part one</button>
<% end sub %>
<%
sub callback(action)
if action = "add" then page.return(2 + 3)
end sub
%>
<%
sub main()
id = page.QS("id") ' = request.queryString("id")
name = page.RF("name") ' = request.form("name")
save = page.RFHas("save") 'checks if "save" is not empty
'automatically try to parse a querystring value into an integer.
id = str.parse(page.QS("id"), 0)
end sub
%>
<%
'container with an array as datasource
set dc = (new DataContainer)(array(1, 2, 3))
'container with a dictionary as datasource
set dc = (new DataContainer)(lib.newDict(1, 2, 3))
'container for a recordset
set dc = (new DataContainer)(lib.getRS("SELECT * FROM table"))
%>
<%
set dc = (new DataContainer)(array(1, 2, 3))
'check if a given value exists in the container
dc.contains(2)
'its even possible in one line
((new DataContainer)(array(1, 2, 3))).contains(2)
%>
<%
set dt = new Datatable
set page = new AjaxedPage
page.draw()
sub init()
dt.sql = "SELECT * FROM user"
dt.sort = "firstname"
end sub
sub callback(a)
dr.draw()
end sub
sub main()
dt.draw()
end sub
%>
<% dt.newColumn("firstname", "Firstname")%>
<%
set c = dt.newColumn("firstname", "Firstname")
c.cssClass = "colFirstname"
%>
<%
dt.selection = "multiple"
dt.onRowCreated = "onRow"
sub onRow(callerDT)
callerDT.row.selected = callerDT.row.number <= 10
end sub
%>
<% (new Dropdown)("SELECT * FROM table", "name", "selected").toString() %>
<% (new Dropdown)(lib.range(1, 12, 1), "month", month(date())).toString() %>
<%
'simple number
output = (new JSON)("myNum", 2, false)
'generates {"myNum": 2}
'array with different datatypes
output = (new JSON)("anArray", array(2, "x", null), true)
'generates "anArray": [2, "x", null]
'(note: the last parameter was true, thus no surrounding brackets in the result)
%>
<%
'by default we disable the logging
AJAXED_LOGLEVEL = 0
sub envDEV()
'but we enable it on the dev environment
AJAXED_LOGLEVEL = 1
end sub
%>
<%
lib.logger.debug("some debug message")
lib.logger.warn("a warning like e.g. use method A instead of B")
lib.logger.info("user logged in")
lib.logger.error("some error happend")
%>
<%
set r = new RSS
r.url = "http://somehost.com/somefeed.xml"
r.load()
if r.failed then lib.error("could not read feed. could be down or wrong format")
for each it in r.items
str.write(r.title & "<br>")
next
%>
<%
set output = new StringBuilder
output("some text")
output("some other text")
%>
<%= output.toString() %>
<!--#include virtual="/ajaxed/class_TestFixture/testFixture.asp"-->
<%
set tf = new TestFixture
tf.run()
sub test_1()
tf.assert 1 = 1, "1 is not equal 2"
'Lets test if our home page works
tf.assertResponse "/default.asp", empty, "<h1>Welcome</h1>", "Welcome page seems not to work"
end sub
%>
Welcome!
Dear <<< name >>>,
Thanks joining us!
We belive your age must be <<< age | not specified >>>.
<%
set t = new TextTemplate
t.filename = "/templateFileName.txt"
t.add "name", "John Doe"
email.subject = t.getFirstLine()
email.body = t.getAllButFirstLine()
%>
<<< BLOCK DETAILS >>>
Name: <<< NAME >>>
<<< BLOCKEND DETAILS >>>
<%
set v = new Validator
if lastname = "" then v.add "lastname", "Lastname cannot be empty"
if str.parse(age, 0) <= 0 then v.add "age", "Age must be a number and greater than 0"
if v then
save()
else
str.write(v.getErrorSummary("<ul>", "</ul>", "<li>", "</li>"))
end if
%>