RadWindow Close Issue

2 posts, 0 answers
  1. Mahesh Babu
    Mahesh Babu avatar
    44 posts
    Member since:
    Jul 2009

    Posted 05 Aug 2009 Link to this post

    Hi,

    I have a RadWindow in which I have radGrid with three radio buttons(CSV,Excel and PDF). I have two buttons SaveAs and Close. When the user selects any radio button(export type) and click on SaveAs, the user should be able to download the file and SaveAs  should be closed automatically. If the user clicks on Close without clicking on SaveAs, the window should close.

    I am able to close radwindow when I click on close button. But, when I click on SaveAs, the file download is popping up and the RadWindow is not closing. Is there any issue with my code???

    Default.aspx.cs

            protected void btnSaveAs_Click(object sender, EventArgs e)
            {
               if (Session["ReportPager"] != null)
                {
                    reportPager = (ReportPager)Session["ReportPager"];
                    SetExportSettings();
                    DownloadData();
                    lblCloseWindow.Text = StringHelper.GetRadWindowCloseScript();
                }
            }

            protected void btnClose_Click(object sender, EventArgs e)
            {
                lblCloseWindow.Text = StringHelper.GetRadWindowCloseScript();
            }

            private void DownloadData()
            {
                //CSV
                if (SelRadioButtonList1.SelectedItem.Text == SelRadioButtonList1.Items[0].Text)
                    this.radGrid.MasterTableView.ExportToCSV();
                //Excel
                else if (SelRadioButtonList1.SelectedItem.Text == SelRadioButtonList1.Items[1].Text)
                    this.radGrid.MasterTableView.ExportToExcel();
                //PDF
                else if (SelRadioButtonList1.SelectedItem.Text == SelRadioButtonList1.Items[2].Text)
                    this.radGrid.MasterTableView.ExportToPdf();
            }

            private void SetExportSettings()
            {
                this.radGrid.ExportSettings.ExportOnlyData = true;
                this.radGrid.ExportSettings.IgnorePaging = true;
                this.radGrid.ExportSettings.OpenInNewWindow = true;
            }

             /// <summary>
            /// This function returns script which is used to close RadWindow at runtime.
            /// </summary>
            /// <returns></returns>
            private static string GetRadWindowCloseScript()
            {
                return @"
                <script type='text/javascript'>
                    var oWindow = null;
                    if (window.radWindow)
                        oWindow = window.radWindow;
                    else if(window.frameElement.radWindow)
                        oWindow = window.frameElement.radWindow;
                    var currentWindow = oWindow;
                    currentWindow.Close();
                </script>";
            }
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 06 Aug 2009 Link to this post

    Hello Mahesh,

    Your scenario is not possible and the window should be manually closed in your case. This is a common browser restriction (it is not related to our RadControls) and it cannot be avoided. You will face the same restriction if you are using a standard browser window instead of RadWindow.


    Best wishes,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top