Identifying an AJAX request being raised

3 posts, 0 answers
  1. G S S
    G S S avatar
    85 posts
    Member since:
    Mar 2008

    Posted 26 Nov 2009 Link to this post

    Hi,

    I have a RADTreeView which initiates an AJAX request using the AJAX manager. This will not postback and thus not execute the Page_Load event handler, correct?

    How can I identify then, when the page is not being posted back to the server but an ajax request has been raised by the user clicking an item in the treeview?

    Thanks
  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 26 Nov 2009 Link to this post

    Hello G S S,

    No, this is not correct. Page_Load will execute and IsPostBack will return true.

    Best wishes,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Carl
    Carl avatar
    16 posts
    Member since:
    Mar 2009

    Posted 02 Dec 2009 Link to this post

    If I understood correctly, you also would like to know when an Ajax page cycle is in process. I believe that Telerik also uses existing Microsoft client side JavaScript variables(see below) normally associated with PostBacks for submitting Ajax calls to the server via XMLHttpRequest. If true, even though it is really not a PostBack by a XMLHttpRequest call to the server, the Page just thinks that a PostBack is in progress during an AJax call to the server. If true, I would imagine this is done to keep from breaking the normal operation of the page.

    You can use the isAjaxRequest property of the RadAjaxManager instance to identify when an Ajax call is in progress. If you are really curious you can inspect the Request.Forms collections and see how Telerik makes use of the underlying PostBack variables.

    For  a simple example I worked up, here is what was returned from an Ajax call to the server:

    Request.Form["ScriptManager1"] "AjaxMgrSU|AjaxMgr"  // Telerik house keeping
    Request.Form["__EVENTTARGET"] "AjaxMgr"   // ClientID of the RadAjaxManager
    Request.Form["__EVENTARGUMENT"] "firstName=Carl&lastName=Taylor"  // My stuff, just a simple string to their architecture
    Request.Form["__ASYNCPOST"]      "true"

    I am new to Telerik's way of doing this myself. I have developed a cross browser JavaScript class for using an instance of the XMLHttpRequest Object which is underlying communication mechanism to/from the server for doing AJax.  I typically hit another page that is dedicated to handeling Ajax calls. This keeps me from having to mess with keeping the PostBack and Ajax calls from getting all tangeled up.  My JavaScript class formats the data being sent to the server to where it just looks like a typical Request.Forms collection. My class also provides an optional grayed out translucent hiding div and "please wait" graphic during the call.
     
    One of the questions that I am about to post myself is how they keep all the normal page content that is built during the Page Cycle from being returned at the end of the Ajax call on the server. With what I do with my class, all that gets returned is JavaScript built on the server which script on the client does an eval on. So it is pretty efficient.

    Since I am creating/updating some custom stuff on the client. I am trying to figure out whether I go with Telerik or my own stuff for this particular page.

    In closing, please keep in mind that I am no expert, so please verify what I have told you because some of it could be incorrect.

    Best regards,
    Carl Taylor
    Suwanee, GA




      

Back to Top