This is a migrated thread and some comments may be shown as answers.

Close radwindow after Database Update

3 Answers 78 Views
Window
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 08 Oct 2013, 06:53 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Oct 2013, 10:23 AM
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.
0
Kevin
Top achievements
Rank 1
answered on 09 Oct 2013, 12:54 PM
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






























0
Kevin
Top achievements
Rank 1
answered on 09 Oct 2013, 07:06 PM
Hi Shinu,

Never mind Post, I had some code at top of my if Isnotpostback that was wrong.  thanks for the help.
Tags
Window
Asked by
Kevin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Share this question
or