Client Callback Update->Refresh functionality

Last post 02-16-2006 3:59 PM by drdexter33. 6 replies.

Sort Posts:

  • Client Callback Update->Refresh functionality

    02-14-2006, 4:50 PM
    • Loading...
    • drdexter33
    • Joined on 06-18-2003, 5:05 AM
    • Wilmington, North Carolina
    • Posts 558

    I have a client callback function that calls a webservice in a codebehind page and UPDATES a record in a database. 

    The return from the webservice is a string value that tells the user whether the UPDATE was successful.

    ----------------------------------------------------------------------

    The Javascript

    ----------------------------------------------------------------------

    function UpdateStatus()

    {

    var context = '';

    var message = 'UpdateStatus' + '~' + document.all.txtConHandle.value + '~' + document.all.hdnStatus.value;

    <%= mUpdateStatus %>

    <%= mGetQDataCallBack  %>

    }

    ----------------------------------------------------------------------

    The Callback event reference

    ----------------------------------------------------------------------

     

    mUpdateStatus = this.ClientScript.GetCallbackEventReference(this, "message", "UpdateQMessage", "context", true);

    mGetQDataCallBack = this.ClientScript.GetCallbackEventReference(this, "message", "BuildQTable", "context",true);

     

    ----------------------------------------------------------------------

    The RaiseCallbackEvent method

    ----------------------------------------------------------------------

    public string eventArg;

    public void RaiseCallbackEvent(string eventArg)

    {

    this.eventArg = eventArg;

    }

    ----------------------------------------------------------------------

    The GetCallbackResult method

    ----------------------------------------------------------------------

    public string GetCallbackResult()

    {

    if(delete)   

             string deleteStatus = qmWS.DeleteStudies(someValue);

             return deleteStatus;

    }

    else if(refresh){

       string xmlStudies = qmWS.GetXMLStudiesByQueueName(someValue);

       return xmlStudies;

    }

    The problem is that when the UPDATE succeeds, I need to call another ClientCallback function to refresh the data.  I think that part of the problem is the callback is asynchronous, however I'm not too sure.

    Regardless, The refresh logic isn't working after <%= mUpdateStatus %> is called.

    The application goes into an endless loop.

    Do I need to check for the XMLHTTP Status before I do the refresh Logic?

    How Can I fix this?

     

    Thanks.

     

    Doug Dexter


  • Re: Client Callback Update->Refresh functionality

    02-14-2006, 6:12 PM
    • Loading...
    • rstrahl
    • Joined on 08-20-2003, 1:08 PM
    • Paia, Hawaii
    • Posts 249
    • TrustedFriends-MVPs

    Hi Doug,

    Client Callbacks are asynchronous so if you want to handle one event after the other you should fire the second callback from the client at the end of the first event handler.  IOW, call the second client callback from within UpdateQMessage on the client

    +++ Rick ---

    Rick Strahl [MVP]
    West Wind Technologies
    Making waves on the Web
    www.west-wind.com/weblog
  • Re: Client Callback Update->Refresh functionality

    02-15-2006, 8:40 AM
    • Loading...
    • drdexter33
    • Joined on 06-18-2003, 5:05 AM
    • Wilmington, North Carolina
    • Posts 558

    Hey Rick.

    Thanks for your reply...

    Well, I'm not too sure that I understand what you are saying but I think that you're saying that I should call the second callback from the event handler, or in my case the button onClick event that fires the update method.

    The function that is tied to the onClick() event is UpdateStatus():

    <input id="btnStatusUpdate" class="buttons" type="button" value="Update Status" onclick="UpdateStatus();" />

    Which is (as in previous post) this:

    function UpdateStatus(){

    var context = '';

    var message = 'UpdateStatus' + '~' + document.all.txtConHandle.value + '~' + document.all.hdnStatus.value;

    <%= mUpdateStatus %>

    <%= mGetQDataCallBack  %>

    }

    And in your post you stated:

    "...should fire the second callback from the client at the end of the first event handler"

    Isn't that what I am currently doing?

    Thanks!

    Doug

     

     


  • Re: Client Callback Update->Refresh functionality

    02-15-2006, 9:11 AM
    • Loading...
    • drdexter33
    • Joined on 06-18-2003, 5:05 AM
    • Wilmington, North Carolina
    • Posts 558

    Well.

    I may have found what the source of problem is:

    http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=1e38043e-5957-4c52-b75f-4deb484ced36

    Seems that when you call 2 client callbacks in rapid succession, as in our case

    UPDATE, then REFRESH (both async calls)

    It fires this error:

    PendingCallbacks[...].async is empty or it is not an object

    ...Haven't figured out a fix yet though, although there is one posted here....

    http://lab.msdn.microsoft.com/productfeedback/ViewWorkaround.aspx?FeedbackID=FDBK36231#1

    Just not sure how to implement it yet, and Microsoft hasn't shown the workaround in any type of programming context...

    When or if I find the fix, I'll post it here...

    Blessings...

    Doug

    PS: There's also a list of people here experiencing the same issue:

    http://west-wind.com/weblog/posts/2694.aspx

    Scroll to the FEEDBACK section at the bottom of the page

     

     

     


  • Re: Client Callback Update->Refresh functionality

    02-15-2006, 2:39 PM
    • Loading...
    • TJmaster
    • Joined on 02-05-2006, 3:48 PM
    • Posts 22

    I cant understand why are u doing this soo complex CallBack, please try to do the same with FastPage maybe ... I would like to discuss this in my ICQ 258-225-821 or by email: webprogmaster@hitline.net.ua!!!

    http://fastpage.more.at

    FastPage - AJAX for laziness ASP.NET developers
  • Re: Client Callback Update->Refresh functionality

    02-15-2006, 2:50 PM
    • Loading...
    • drdexter33
    • Joined on 06-18-2003, 5:05 AM
    • Wilmington, North Carolina
    • Posts 558

    Show me an easier way and I'll do it!

    But it looks like you're trying to sell me something!

     

     


  • Re: Client Callback Update->Refresh functionality

    02-16-2006, 3:59 PM
    • Loading...
    • drdexter33
    • Joined on 06-18-2003, 5:05 AM
    • Wilmington, North Carolina
    • Posts 558

    Ok.. Couldn't solve the problem.

    So I went to a straight AJAX(client-side) call to the web service(C#)..and went around using the code-behind..callbacks..

    Since our intranet uses IE 5 or better I used the webservice.htc which allows you to make method calls directly to .Net web services using SOAP.

    http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/behaviors/library/webservice/default.asp

    Pretty cool actually.

    There's a how to in the new Wrox Professional Ajax book on page 177..

    I'll try to put together a doc over the weekend and post it somewhere...maybe someone else can use it..

    Doug...


Page 1 of 1 (7 items)
Microsoft Communities
Page view counter