Results 1 to 3 of 3

Thread: [RESOLVED] Close the Popup After Update

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Resolved [RESOLVED] Close the Popup After Update

    Good Morning All

    I am Opening a Page as a Popup i am using Telerik WIndow which has similar functionality when opening a Popup like this

    Code:
     function OpenPopUp(val_real, vis) {
                var myWidth = 0, myHeight = 0;
                if (typeof (window.innerWidth) == 'number') {
                    //Non-IE
                    myWidth = window.innerWidth;
                    myHeight = window.innerHeight;
                } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
                    //IE 6+ in 'standards compliant mode'
                    myWidth = document.documentElement.clientWidth;
                    myHeight = document.documentElement.clientHeight;
                } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                    //IE 4 compatible
                    myWidth = document.body.clientWidth;
                    myHeight = document.body.clientHeight;
                }
    
                myWidth = myWidth / 2 - 150;
                myHeight = myHeight / 2 - 50;
                window.open('MyPage.aspx?Val=' + val_read, 'width=700,height=160,top=' + myHeight + ',left=' + myWidth)
                return false;
    
            }
    this "myPage.aspx" page has a button that person some updates to the Database on the server side. This is opened as a popup and there is a grid below , so what i want to do after the Update to the Database has happened , i want to refresh the Grid, i have this code
    Code:
         //This code is used to provide a reference to the radwindow "wrapper"
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)				
                return oWindow;
            }
    
            function CloseOnReload() {
                //alert("Dialog is about to close itself");
                GetRadWindow().close();
                RefreshParentPage();
            }
    
            function RefreshParentPage() {
                //alert("Dialog is about to reload parent page");
                GetRadWindow().BrowserWindow.location.reload();
            }
    
            function RedirectParentPage(newUrl) {
                alert("Dialog is about to redirect parent page to " + newUrl);
                GetRadWindow().BrowserWindow.document.location.href = newUrl;
            }
    
            function CallFunctionOnParentPage(fnName) {
                alert("Calling the function " + fnName + " defined on the parent page");
                var oWindow = GetRadWindow();
                if (oWindow.BrowserWindow[fnName] && typeof (oWindow.BrowserWindow[fnName]) == "function") {
                    oWindow.BrowserWindow[fnName](oWindow);
                }
            }
    
            function RefreshParentPageWithoutWarning() { 
                GetRadWindow().BrowserWindow.document.forms[0].submit();
            }
    and on the server side i have this

    Code:
                        Response.Write("<Script>return RefreshParentPageWithoutWarning();</script>")
    or

    Code:
    SavetoDB(Values)
    
     ScriptManager.RegisterStartupScript(Page, Me.GetType(), "", "RefreshParentPageWithoutWarning()", True)
    My problem here is that it Refresh the page before it does a Database Update, and if it refreshes the page , the Database update ends up not being done.

    Thanks

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Close the Popup After Update

    Ok, I am confused.

    Where is the code that does the Database update? Surely if you place the code to refresh the page, after the code to do the Database Update, then it should work as expected.

    Gary

  3. #3

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: Close the Popup After Update

    hi Gary , long time, hope you are fine.


    i was also suprised why it does not work, but i changed the code to this
    Code:
    SavetoDB(Values) 'Code that saves to the DB
    
    Page page = HttpContext.Current.Handler as Page;
    
    ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "CloseOnReload();", true);
    and it worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width