locked
Closing SP.UI.ModalDialog.showWaitScreenWithNoClose not working with update panel RRS feed

  • Question

  • Hi,

    I am using SP.UI.ModalDialog.showWaitScreenWithNoClose method for displaying wait screen in sharepoint visual webpart.

    I have referred following link http://bernado-nguyen-hoan.com/2012/04/23/how-to-close-sharepoint-modal-wait-screen-after-postback-when-page-is-in-dialog-mode/.

    I have to show wait screen on selectedindexchanged event of a dropdownlist. It is working fine if dropdownlist is not inside updatepanel.

    If dropdownlist is placed inside an update panel, the wait screen is not getting closed automatically. How to get this working with update panel?


    Regards, Shruti

    Monday, July 16, 2012 8:59 AM

All replies

  • Hi Shruthi,

    As mentioned in your post,i have refered the code in the link http://bernado-nguyen-hoan.com/2012/04/23/how-to-close-sharepoint-modal-wait-screen-after-postback-when-page-is-in-dialog-mode/. That is really a cool code but it works for a normal page without an update panel. Please see my code below. I have modified the code on button click.

     protected void btnDoWork_Click(object sender, EventArgs e)
            {
    
    
    
                //Simulate a time consuming operation
    
                System.Threading.Thread.Sleep(3000);
    
                //Emit the script that will close the wait screen. We only need to do this when
    
                //the app page is in dialog mode, in which case window.frameElement will NOT be null
    
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "CloseWaitDialog", @" <script language='javascript'>
    
                var parentObject = window.frameElement;
    
               if (parentObject != null) {
    
            var waitDialog = parentObject.waitDialog;
    
            if (waitDialog != null) {
    
                waitDialog.close();
    
            }
    
        }
    
    </script>", true);
    
               
    
    
            }

    if you have noticed the code.i have changed the method  this.ClientScript.RegisterStartupScript(this.GetType(), "CloseWaitDialog","<your js script>"); to ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "CloseWaitDialog","<your js script>"); .

    The regsiter client script method with the overload method mention in the blog wont work for update panel.So i have changed with the one which works fine with update panel.Try and let me know if you face any issues

    
    



    • Edited by Naveen_D Sunday, July 29, 2012 3:38 AM
    Sunday, July 29, 2012 3:34 AM
  • Hi Naveen,

    Thanks for your reply, but I have already tried using ScriptManager.RegisterClientScriptBlock method and still faced same issue. I even used the method with updatepanel control and updatepanel's type, but that also didn't work.


    Regards, Shruti

    Monday, July 30, 2012 4:11 AM
  • Hi Shruti,

    Will you post your code ?.The code you have written in selectedindexchanged event .

    Monday, July 30, 2012 5:58 AM
  • Hi Naveen,

    Below is the code for SelectedIndexChanged event.

    protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e) { try { //some code here } catch (Exception) { } ScriptManager.RegisterStartupScript( this.updpanel, this.updpanel.GetType(), "CloseWaitDialog", @" var parentObject = window.frameElement; if (parentObject != null) { var waitDialog = parentObject.waitDialog; if (waitDialog != null) { waitDialog.close(); } } ", true); }

    Actually I have a doubt if this is possible, as in this block window.frameElement is null. Which is also correct I suppose because this code will get executed from an event of the control which is inside update panel,, therefore it will not be able to access window.frameElement. I am not sure though if I am correct .

    


    Regards, Shruti

    Monday, July 30, 2012 6:30 AM
  • Hi Shruti,

    Copy paste the below js function in your webpart page.After that modify the ScriptManager.RegisterStartupScript   as given below.Dont forget to do ctrl+F5 in your browser once you deploy the latest change in js

    <script type="text/javascript">
    function closeWait()
    {
    var parentObject = window.frameElement;
                 if (parentObject != null) {
                  var waitDialog = parentObject.waitDialog;
               if (waitDialog != null) {
                            waitDialog.close();
    }
    </script>
    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(),"CloseWaitDialog", "closeWait();", true);


    Monday, July 30, 2012 6:55 AM
  • Else you can try this also.Dont forget to do ctrl + F5 in your browser after deployment.

    protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
            {
                try
                {
    //some code here
                    
                }
                catch (Exception) { }
                ScriptManager.RegisterClientScriptBlock( this.Page, this.GetType(), "CloseWaitDialog", @"
    var parentObject = window.frameElement;
                 if (parentObject != null) {
                  var waitDialog = parentObject.waitDialog;
               if (waitDialog != null) {
                            waitDialog.close();
     } } ", true);
            }

    Monday, July 30, 2012 6:59 AM
  • Hi Naveen,

    Thanks for your reply.

    I had tried this as well but still couldn't get it working.

    I had mentioned in my previous reply that window.frameElement is returning null, so will not be able to get dialog window's object.


    Regards, Shruti

    Monday, July 30, 2012 8:35 AM
  • Hi There

    Better late than never but the issue is:

    window.frameElement

    This will return null you want:

    window.parent

    Just tested it and it works fine.

    Cheers

    Sebastian

    Saturday, March 15, 2014 4:47 PM