Close the Popup After Update

3 posts, 0 answers
  1. Vuyiswa
    Vuyiswa avatar
    223 posts
    Member since:
    Jan 2010

    Posted 22 Feb 2012 Link to this post

    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 

    function OpenPopUp(val_real, vis) {
              var myWidth = 0, myHeight = 0;
              if (typeof (window.innerWidth) == 'number') {
                  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;
    '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 
    //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");
         function RefreshParentPage() {
             //alert("Dialog is about to reload parent page");
         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") {
         function RefreshParentPageWithoutWarning() {

    and on the server side i have this 

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


    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. 

  2. rdmptn
    rdmptn avatar
    72 posts
    Member since:
    Aug 2011

    Posted 24 Feb 2012 Link to this post

    The scripts registered via the script manager or Response.Write() are executed only when they are received on the client. This happens after all server-side code has finished processing so the final response can be prepared and sent to the client. I am attaching here an image that illustrates the lifecycle of an aspx page. The above means that if a database insert is not performed the most likely reason for this is in its server code, not in the page reload. I also see that you are not opening a RadWindow, but a regular browser window with your first JavaScript snippet, so the JavaScript inside the second page would hardly work. Nevertheless, if you are convinced the page reload is the cause you can delay it with setTimeout() method (often 0ms suffice just to let the browser finish work, but you can give it several seconds if you like) or you can utilize the Sys.Appilication.Load event when injecting the script to have the content page fully loaded before refreshing.
  3. Vuyiswa
    Vuyiswa avatar
    223 posts
    Member since:
    Jan 2010

    Posted 24 Feb 2012 Link to this post


    i have resolved the issue  like this 

    Dim page As Page = HttpContext.Current.Handler
    ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "CloseOnReload();",
Back to Top