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

RadWindow Close Issue

1 Answer 93 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mahesh Babu
Top achievements
Rank 1
Mahesh Babu asked on 05 Aug 2009, 06:54 AM
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>";
        }

1 Answer, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 06 Aug 2009, 01:09 PM
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.
Tags
Window
Asked by
Mahesh Babu
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or