Close Parent Window from RadTab

2 posts, 0 answers
  1. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 20 Aug 2013 Link to this post

    there are several tabstrip in my aspx page, when use click on the tab, it will redirect to another aspx.

    - RabTab1 (page1.aspx)
    - RabTab2 (page2.aspx)

    how can i close the whole window (parent.aspx) when user already click RadTab2 and enter into (page2.aspx) ?





    <head runat="server">
        <title>Position Details</title>
        <script type="text/javascript">
            function UpdateRefresh() {
                if (window.opener)
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <telerik:RadSplitter ID="RadSplitter1" runat="server" Width="100%" Height="100%" Orientation="Horizontal">
            <telerik:RadPane ID="rpTitle" runat="server" BackColor="#003399" Height="27px" MinHeight="27" MaxHeight="27" Width="100%" Scrolling=None>
                <asp:Table ID="Table1" runat="server" Width="100%" Height="100%">
                <asp:TableCell Width="33%">
                    <asp:Label ID="lblPositionCode" runat="server" Text="" ForeColor="White" Font-Size="12pt" Font-Bold="true"></asp:Label>
                <asp:TableCell Width="33%" HorizontalAlign="Center">
                    <asp:Label ID="lblPositionName" runat="server" Text="" ForeColor="White" Font-Size="12pt" Font-Bold="true"></asp:Label></asp:TableCell>
                <asp:TableCell Width="34%" HorizontalAlign="Right">
                    <asp:Label ID="lblDepartment" runat="server" Text="" ForeColor="#FFCC00" Font-Size="12pt" Font-Bold="true"></asp:Label>
            <telerik:RadPane ID="rpTab" runat="server" Height="26px" MinHeight="26" MaxHeight="26" Width="100%">
                <telerik:RadTabStrip ID="rtMenu" runat="server" Skin="Outlook" 
                    <telerik:RadTab Text="History" Value="History" Selected="True" Width="100px"></telerik:RadTab>
                    <telerik:RadTab Text="Details" Value="Details" Width="100px"></telerik:RadTab>
                    <telerik:RadTab Text="Compliance" Value="Compliance" Width="100px"></telerik:RadTab>
                    <telerik:RadTab Text="Competency" Value="Competency" Width="100px"></telerik:RadTab>
                    <telerik:RadTab Text="Procedure" Value="Procedure" Width="100px"></telerik:RadTab>
                    <telerik:RadTab Text="Succession" Value="Succession" Width="100px"></telerik:RadTab>
            <telerik:RadPane ID="rpContent" runat="server">

    Code behind:


    Protected Sub rtMenu_TabClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTabStripEventArgs) Handles rtMenu.TabClick
        If e.Tab.Value = "History" Then
            rpContent.ContentUrl = "PositionHistory.aspx?PosID=" & Request("PosID")
        ElseIf e.Tab.Value = "Details" Then
            rpContent.ContentUrl = "PositionInfo.aspx?PosID=" & Request("PosID")
        ElseIf e.Tab.Value = "Succession" Then
            rpContent.ContentUrl = "SuccessionPlanning.aspx?PosID=" & Request("PosID")
        ElseIf e.Tab.Value = "Compliance" Then
            rpContent.ContentUrl = "Compliance.aspx?PosID=" & Request("PosID")
        ElseIf e.Tab.Value = "Competency" Then
            rpContent.ContentUrl = "Competency.aspx?PosID=" & Request("PosID")
        ElseIf e.Tab.Value = "Procedure" Then
            rpContent.ContentUrl = "Procedure.aspx?PosID=" & Request("PosID")
        End If
    End Sub

    i had tried to add the following function in child page code behind, but none of them work

    'auto close browser 
    Response.Write("<script type='text/javascript'> " & "window.opener = 'Self';" & "'','_parent','');" & "window.close(); " & "</script>") 
    Me.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Close", "window.close()", True) 
    Page.ClientScript.RegisterOnSubmitStatement(GetType(Page), "closePage", "window.onunload = CloseWindow();") 
    Response.Write("<script type='text/javascript'> " & "window.opener = 'Self';" & "'','_parent','');" & "window.close(); " & "</script>") 
    Page.ClientScriptManager.RegisterClientScriptBlock(Me.[GetType](), "RedirectScript", "window.parent.location = '../Images/Logo_Done.jpg'", True) 
    Page.ClientScript.RegisterStartupScript([GetType](), "Load", "<script type='text/javascript'>window.parent.location.href = '../Images/Logo_Done.jpg'; </script>")
  2. Dimitar Terziev
    Dimitar Terziev avatar
    1266 posts

    Posted 23 Aug 2013 Link to this post

    Hello Joe,

    Could you specify the browser that you are using, because some browsers have limitation on closing the window using javascript. In case you are targeting IE and the child page is in the same domain as the parent, the following code should work:
    <asp:Button Text="Click" ID="button1" OnClientClick="CloseWindow(); return false;" runat="server" />
        function CloseWindow() {

    If you are targeting other browsers than IE, then the following forum thread could be useful.

    Dimitar Terziev
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top