Close radwindow after Database Update

4 posts, 1 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 08 Oct 2013 Link to this post

    I see some posts on here of closing the Radwindow from server and client.  What I am wondering if there are any easier ways now with the updated releases from telerik.    Need to Close my radwindow on this button click and then refresh the page.  If there and easy way to do on the code side.  Instead of the scriptmanager below I would put in the close radwindow.

    Protected Sub lnkVerify_Click(sender As Object, e As EventArgs) Handles lnkVerify.Click
           Dim returnV As String = ""
     
           sql = "exec usp_AnnualSignHR '" & Replace(HFDigSig.Value, "'", "''") & "', '" & HFEDIPI.Value & "'"
     
           returnV = getData(sql).Rows(0)(0)
     
           If returnV = "0" Then
               pnlGrid.Visible = False
               ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "OpenWindow", "alert('Thank you for signing your annual hand receipt. You will be redirected to your Hand Receipt');", True)
               Response.Write("<meta HTTP-EQUIV=""refresh"" content=""1;url=~/User/UserHR.aspx"">")
           Else
               ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "OpenWindow", "alert('There has been an problem please contact the help desk.');", True)
           End If
       End Sub
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Oct 2013 Link to this post

    Hi Kevin,

    Please try the following code snippet to Close the RadWindow in code behind. Please go through this forum which deals the same scenario.

    JavaScript:
    <script type="text/javascript">
        function openRadWindow(sender, args) {
            var radwindow = $find('<%=RadWindow1.ClientID %>');
            radwindow.show();
        }
        function closeWin() {
            GetRadWindow().close();
        }
        function GetRadWindow() {
            var oWindow = null; if (window.radWindow)
                oWindow = window.radWindow;
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow; return oWindow;
            refreshParentPage(); //to reload the page
        }
        function refreshParentPage() {
            GetRadWindow().BrowserWindow.location.reload();
        }
    </script>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        string script = "function f(){closeWin(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 09 Oct 2013 Link to this post

    Hi Shinu,

    Thanks for the help, but here is what its doing for me.  It keeps opening a Radwindow within a Radwindow for some reason.  I have some of this code on my main page already from a pages that I dont need the postback to happen.  Here is the code I have on my main page.

    function LoadWindow(TypeWin) {
                  var radHr = $find("<%= radHrproblem.ClientID%>");
                  var Pers = document.getElementById("<%= HFPersId.ClientID%>").value;
                  var pnlShow = $find("<%= pnlAnnualHr_MPE.ClientID%>").hide()
                  if (TypeWin == 1) {
                      radHr.setUrl("../User/HRProb.aspx?User=" + Pers);
                  }
                  else if (TypeWin == 2) {
                      radHr.setUrl("../Reports/AnnualHRSign.aspx");
                  }
                  radHr.show();
                  radHr.maximize();
              }
     
              function RefreshParentPage() {
                  document.location.reload();
              }

    Here is the code I just put in the lastest page i am bring into a Radwindow which I am using the psotback on, but it keeps reopening a Radwindow inside the existing radwindow that was popped up.
    function closeWin() {
                   GetRadWindow().close();
               }
     
               function GetRadWindow() {
                   var oWindow = null; if (window.radWindow)
                       oWindow = window.radWindow;
                   else if (window.frameElement.radWindow)
                       oWindow = window.frameElement.radWindow; return oWindow;
                   refreshParentPage(); //to reload the page
               }
               function refreshParentPage() {
                   GetRadWindow().BrowserWindow.location.reload();
               }
     
     
    Protected Sub lnkVerify_Click(sender As Object, e As EventArgs) Handles lnkVerify.Click
           Dim returnV As String = ""
     
           sql = "exec usp_AnnualSignHR '" & Replace(HFDigSig.Value, "'", "''") & "', '" & HFEDIPI.Value & "'"
     
           returnV = getData(sql).Rows(0)(0)
     
           If returnV = "0" Then
               'pnlGrid.Visible = False
               Dim script As String = "function f(){closeWin(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
               ScriptManager.RegisterStartupScript(Page, Page.[GetType](), "key", script, True)
           Else
               ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "OpenWindow", "alert('There has been an problem please contact the help desk.');", True)
           End If
       End Sub






























  5. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 09 Oct 2013 Link to this post

    Hi Shinu,

    Never mind Post, I had some code at top of my if Isnotpostback that was wrong.  thanks for the help.
Back to Top