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

Close Parent Window from RadTab

1 Answer 74 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 21 Aug 2013, 03:49 AM
there are several tabstrip in my aspx page, when use click on the tab, it will redirect to another aspx.

example
Parent.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)
                window.opener.UpdateRefresh();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <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:TableRow>
            <asp:TableCell Width="33%">
                <asp:Label ID="lblPositionCode" runat="server" Text="" ForeColor="White" Font-Size="12pt" Font-Bold="true"></asp:Label>
            </asp:TableCell>
            <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>
            </asp:TableCell>
            </asp:TableRow>
            </asp:Table>
        </telerik:RadPane>
        <telerik:RadPane ID="rpTab" runat="server" Height="26px" MinHeight="26" MaxHeight="26" Width="100%">
            <telerik:RadTabStrip ID="rtMenu" runat="server" Skin="Outlook" 
                SelectedIndex="0">
            <Tabs>
                <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>
            </Tabs>
            </telerik:RadTabStrip>
        </telerik:RadPane>
        <telerik:RadPane ID="rpContent" runat="server">
        </telerik:RadPane>
    </telerik:RadSplitter>
    </form>
</body>
</html>

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';" & "window.open('','_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';" & "window.open('','_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>")

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 23 Aug 2013, 07:51 AM
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" />
<script>
    function CloseWindow() {
        window.parent.close();
    }
 
</script>

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

Regards,
Dimitar Terziev
Telerik
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.
Tags
TabStrip
Asked by
Joe
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or