Posted by malakablog on May 1, 2009
- Implement an AjaxMethod to return IDictionary object
[AjaxPro.AjaxMethod]
public IDictionary AjaxGetIDictionary()
{
//Prepare the IDictionary object
}
- Use JavaScript to request the AjaxMethod AjaxGetIDictionary
MyAjaxClass. AjaxGetIDictionary (jsAjaxGetIDictionary_Callback);
- In the JavaScript function jsAjaxGetIDictionary_Callback add the IDictionary items to the DopDownList
function jsAjaxGetIDictionary (response)
{
try
{
var DictionaryItems= response.value;
if (DictionaryItems == null || typeof(DictionaryItems) != “object”)
{
return;
}
var myDropDownList = document.getElementById(“myDropDownList”);
myDropDownList.options.length = 0;
for (var i = 0; i < response.value.length; ++i)
{
myDropDownList.options[myDropDownList.options.length] = new Option(response.value[i].Value,response.value[i].Key);
}
}
catch(e)
{
}
}
Posted in Uncategorized | Tagged: AJAX, ajaxPro, ASP.NET, beginner, code, development, HTML, JavaScript, Programming, web | Leave a Comment »
Posted by malakablog on July 16, 2008
This is a simple guide for using the AJAX Pro in VS2003
1- Add the AJAXPro.dll to your bin folder
- Right click on the bin folder and select “Add Reference… ”

- Select the browse tab and browse for the AjaxPro.dll folder to select it and click ok

2- Add the following to your web.config file
<httpHandlers>
<add verb=“POST,GET“ path=“ajaxpro/*.ashx“ type=“AjaxPro.AjaxHandlerFactory, AjaxPro.2“/>
</httpHandlers>
3- Create a Class to write your Ajax functions
- Right Click on the App_Code folder and select “Add New Item…”

- Select “Class” from the templates; enter a name for your class and click Add

4- In your class imports the AjaxPro Library and create your function as the following:
<AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)> _
Public Function AjaxFunction(ByVal strVariable As String) As String
5- In the ASP Page that need to use the Ajax Function:
- Import your Ajax Class library
- Add a function to the body onload event
<body onload=”BodyOnLoad()”
- In the BodyOnLoad assign a variable to your class
function BodyOnLoad()
{
LPMyAjax = IMGSLB.MyAjax;
}
6- Now you can call the ajax function from JavaScript
function jsCallAjax(strValue)
{
try
{
LPMyAjax.AjaxFunction(strValue,jsCallAjaxCallback);
}
catch(err)
{
alert(err.message)
}
finally
{
}
}
Posted in Uncategorized | Tagged: AJAX, ajaxPro, ASP.NET, beginner, code, development, HTML, JavaScript, Programming, web | 1 Comment »
Posted by malakablog on May 27, 2008
so this is a Java Script code that use synchronous ajaxpro Method
var toReturn = MyAjaxClass.MyAjaxMethod(sVariable).value;
to change it to use Asynchronous method it would look like this:
MyAjaxClass.MyAjaxMethod(sVariable,MyAjaxMethodCallback);
MyAjaxMethodCallback is a Java Script function to handle the return value from the Ajax method, it could be like this
function MyAjaxMethodCallback(toReturn)
{
alert(toReturn.value);
}
That’s it….
Posted in Uncategorized | Tagged: AJAX, ajaxPro, code, development, JavaScript, Programming | Leave a Comment »