CodeGuru
Earthweb Search
Login Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> .NET / C# >> .NET >> General ASP.NET >> Web Forms


Callback and Controls Rendering (Manual Partial Page Rendering)
Rating: none

Muhammad Adnan Amanullah (view profile)
January 29, 2008

Go to page: Prev  1  2  3  4  

<script language="javascript" type="text/javascript">
//Runs when GetCallbackResult() executes and return result through
//arg param
function ReceiveServerData(arg, context)
{
//split command and contents (rendered data)
   var cmd_content = arg.split(',');
   //check command
   if (cmd_content[0] == 'LoadSubCategory')
   {
      //set rendered contents to sub category div to show
      //subcategories according to categories
      document.getElementById('ddlSubcategories').innerHTML =
        cmd_content[1];
   }
   else
   {
   //set rendered contents to products div to show products
   //according to categories and sub categories
    document.getElementById('grvProducts').innerHTML =
      cmd_content[1];
   }

}

//invoke by categories/subcategories dropdownlist to communicate
//with server for processing
function CallSrv(ddl)
{
   //check command and determine either this method invoked by
   //Categories Dropdownlist or by Subcategories Dropdownlist
   if (ddl.id == 'ddlCategories')
   {
      if(ddl.value != 'Select')
      {
         //Set command and value to load data accordingly and call
         //server side method RaiseCallbackEvent
          CallServer('LoadSubCategory' + ',' + ddl.value, '');
      }
   }
   else

      //Set command and value to load data accordingly and call
      //server side method RaiseCallbackEvent

          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  

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
No Comments Posted.
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers