Wednesday, September 29, 2010

AjaxPro

These days we use Ajax technologies in every page for the faster action, to make network traffic less, to refresh the needed parts of the page. We are using Ajax in .net, html, php, java etc.. Among this we are using AjaxPro which is also ajax, but here the codes are precompiled into dll file. Just we have to use this AjaxPro. 

Why we have to use AjaxPro?
The real need arises when we want to communicate directly from javascript to AppCode class files. Means after once form values has been entered we are passing the form values directly into the AppCode class file using Javascript. At that time we are using this AjaxPro. 

There are two methods by which we can use this AjaxPro.
  1. In the first one we fetch the values, and javascript will pass it into one js file. From that js file values are reflected back into aspx page code behind, where in that code behind class will be called.
  2. In second one we fetch the values of the form using Javascript and send it into AppCode class file and there process all the things.
Now lets have a look at the second method:

  1. First we have to place AjaxPro2.dll and its refresh file in the bin folder.
  2. In webconfig file add the following code , inside the

                                                                                   
  3. In aspx page for the particular button click call the javascript function.
  4. Inside the javascript in aspx page write the function code and call the class
    from appcode and function from the appcode class file as ajax.add(name).
    here ajax is the class file and add is the function and pass the parameters.
  5. In codebehind of aspx page add “using System.Text;” & “using AjaxPro”
    namespaces.
  6. Call the appcode class file as normally in the apsx code behind file.
  7. In page_load  event of the aspx page code behind insert the following code :
    AjaxPro.Utility.RegisterTypeForAjax(typeof(ajax));
    Here “ajax” is the appcode classfile name where the corresponding stored
    procedures are there.
  8. In appcode class file add” using AjaxPro” namespace.
  9. On top of each function in classfile add [AjaxMethod] sentence.




No comments:

Post a Comment