Google Brother Up

2008/09/08

AJAX PRO Concept and Example

AJAX PRO


1. In web.config file add the tag below under (system.web) tag: -

(httpHandlers)
(add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/)
(/httpHandlers)

2. Write the TestAjaxPro.aspx file: -

(html xmlns="http://www.w3.org/1999/xhtml" )
(head runat="server")
(title)Test Ajax Pro Page(/title)

(script type="text/javascript")
function getServerTime() // being called from (body)
{
TestAjaxPro.GetServerTimeAjax(getServerTime_callback); // asynchronous call
}

function getServerTime_callback(res) // being called from inside GetServerTimeAjax() parameter
{
alert(res.value);
}
(/script)

(/head)
(body onload="javascript:getServerTime();")
(form id="form1" runat="server" )
(div)

(/div)
(/form)
(/body)
(/html)


3. Write the TestAjaxPro.aspx.cs file: -

using AjaxPro;

public partial class TestAjaxPro : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(TestAjaxPro)); //
}

[AjaxPro.AjaxMethod]
public DateTime GetServerTimeAjax() // being called from getServerTime()
{
return DateTime.Now;
}
}

4. Run the code.


81 unique visitors

No comments:

Drop Down List

1. http://www.janetsystems.co.uk/Articles/NetArticles/tabid/74/itemid/161/modid/449/Default.aspx