Tuesday, January 31, 2006
Introduction to AJAX
DOWNLOAD AJAX LIBRARY
http://www.schwarz-interactive.de/download/5.11.4.2.zip
SAMPLE
http://ajax.schwarz-interactive.de/csharpsample/default.aspx
Download dll from above link and add to References.
Web.Config Settings
--------------------
add handler to section
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
//AJAX Method
[AjaxMethod]
public string GetTextBoxValue(string str)
{
return str;
}
//On form load event
//namespace where class exits and classname where ajax method exist.
Utility.RegisterTypeForAjax(typeof(namespace.classname));
//HTML of the form
<script type="text/javascript">
function GetTextboxValue()
{
//var ele = document.getElementById("txtbox1").value;
HTMLControls.Methods.GetTextBoxValue(document.getElementById("txtbox1").value, GetTextboxValue_callback);
}
function GetTextboxValue_callback(res)
{
alert(res.value);
document.getElementById("txtbox2").value = res.value;
//var ele = document.getElementById("txtbox2");
//ele.innerHTML = res.value;
res = null;
}
</script>
Textbox 1: <input type="text" id="txtbox1" value="1" />
Textbox 2: <input type="text" id="txtbox2" />
Click <a href="javascript:GetTextboxValue();void(0);">Submit</a> to copy value from Textbox1 to Textbox2
Article from www.schwarz-interactive.de
http://www.schwarz-interactive.de/download/5.11.4.2.zip
SAMPLE
http://ajax.schwarz-interactive.de/csharpsample/default.aspx
Download dll from above link and add to References.
Web.Config Settings
--------------------
add handler to section
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
//AJAX Method
[AjaxMethod]
public string GetTextBoxValue(string str)
{
return str;
}
//On form load event
//namespace where class exits and classname where ajax method exist.
Utility.RegisterTypeForAjax(typeof(namespace.classname));
//HTML of the form
<script type="text/javascript">
function GetTextboxValue()
{
//var ele = document.getElementById("txtbox1").value;
HTMLControls.Methods.GetTextBoxValue(document.getElementById("txtbox1").value, GetTextboxValue_callback);
}
function GetTextboxValue_callback(res)
{
alert(res.value);
document.getElementById("txtbox2").value = res.value;
//var ele = document.getElementById("txtbox2");
//ele.innerHTML = res.value;
res = null;
}
</script>
Textbox 1: <input type="text" id="txtbox1" value="1" />
Textbox 2: <input type="text" id="txtbox2" />
Click <a href="javascript:GetTextboxValue();void(0);">Submit</a> to copy value from Textbox1 to Textbox2
Article from www.schwarz-interactive.de