views:

40

answers:

1

I want to display a status message after a server side postback. Currently to do this,

  1. I use blockUI for blocking a div while the save is in progress

  2. I unblock the div with a custom End request handler for my update panel

  3. To display status messages, I use scriptmanager's registerstartupscript() in my try catch block on server side code. All works well, however this displays the status messages before the div is unblocked.

How do I show my success/error messages only after the div has been unblocked ?

+1  A: 

You can try pageLoading or pageLoaded script manager event handers instead of endRequest, i.e.:

<script type="text/javascript" language="javascript"> 
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoadingHandler);
    function PageLoadingHandler(sender, args) 
    {      
         // hide your blockUI div here
    }
</script>

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

Or you have another option. Write message on server callback to hidden field and then in your endRequest handler hide div, check if there is message in hidden field and if message exists display it.

Pavel Morshenyuk
the problem is that since I am using scriptmanager's startup script to display messages, they always get executed first no matter what handler I attach the unblock.
Popo
pageLoading should work: Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated.
Pavel Morshenyuk
I have added another option... but it seems to be dirty hack :)
Pavel Morshenyuk
Popo
Pavel Morshenyuk
Thank Pavel, that was helpful. Cheers.
Popo