Go to page:
Prev 1 2 3 4
<script language="javascript" type="text/javascript">
function ReceiveServerData(arg, context)
{
var cmd_content = arg.split(',');
if (cmd_content[0] == 'LoadSubCategory')
{
document.getElementById('ddlSubcategories').innerHTML =
cmd_content[1];
}
else
{
document.getElementById('grvProducts').innerHTML =
cmd_content[1];
}
}
function CallSrv(ddl)
{
if (ddl.id == 'ddlCategories')
{
if(ddl.value != 'Select')
{
CallServer('LoadSubCategory' + ',' + ddl.value, '');
}
}
else
CallServer('LoadProducts' + ',' + ddl.value, '');
}
}
</script>
That's it. These are the steps you need to use to call and get results from server-side code by using ICALLBACK. Asynchronous output would occur within a millisecond and without Postback.
Conclusion
Callback is a lightweight technique used to call server-side methods asynchronously from JavaScript without any postback and reloading/rendering of unnecessary parts of the page or unnecessary code. So, you can use that when you need to perform any operation at the back end—such as update records in a database. You don't need to send all the content of pages in a request and make that object heavyweight, which could cause slow performance.
About the Author
.Net Evangelist
http://weblogs.asp.net/MuhammadAdnan
http://realfantasy.wordpress.com
http://interviewquestion.wordpress.com
Go to page:
Prev 1 2 3 4