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>";
}
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();
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>";
}