R
Rez
Hi Guys,
I have a problem with exporting to excel from a modal dialog box.
Basically, i have an ASPX page that gathers user criteria, and passes
it to a dialogbox (showModalDialog), There is a grid on the dialog
that will be populated based on the criteria. Since i am doing some
postback on the dialog i have the following tag in the header:
<base target="_self">
Now, I want to export the grid to excel, for doing that i have used
the following code:
private void btnExcel_Click(object sender, System.EventArgs e)
{
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridResult.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
The above code working fine when i don't have the base tag, but with
the base tag, it won't work, and i kind of understand why it doesn't,
but i couldn't find a work-around. Any help/advice would be greatfully
appreciated.
One idea can be this:
Is there any way that i can prevent the tag to be rendered on
btnExcel_Click?
I have tried to override the render method of the tag (by using
SetRenderMethodDelegate), but no success.
I have a problem with exporting to excel from a modal dialog box.
Basically, i have an ASPX page that gathers user criteria, and passes
it to a dialogbox (showModalDialog), There is a grid on the dialog
that will be populated based on the criteria. Since i am doing some
postback on the dialog i have the following tag in the header:
<base target="_self">
Now, I want to export the grid to excel, for doing that i have used
the following code:
private void btnExcel_Click(object sender, System.EventArgs e)
{
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridResult.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
The above code working fine when i don't have the base tag, but with
the base tag, it won't work, and i kind of understand why it doesn't,
but i couldn't find a work-around. Any help/advice would be greatfully
appreciated.
One idea can be this:
Is there any way that i can prevent the tag to be rendered on
btnExcel_Click?
I have tried to override the render method of the tag (by using
SetRenderMethodDelegate), but no success.