views:

19

answers:

1

We have a web part on which we display some data in a grid. We are exporting grid's underlying datatable to Excel and displaying Open - Save - Cancel dialouge box on click of a server side button.

Following is the code we are executing on click of server side button.

this.Page.Response.Clear();
this.Page.Response.AppendHeader("Content-Disposition", "attachment; filename=MyTasks.xls");
this.Page.Response.ContentType = "application/ms-excel";
this.Page.Response.Write("...here goes my well formated html....");
this.Page.Response.End();

Problem is that when i click on Cancel in the diaglouge box then dialogue box to Open/Save excel disappears but all the server side buttons placed on my web part becomes non responsive, on click of any of those buttons their server side click event does not get fired !!!

Any idea ?

Thanks.

A: 

i got it, I had to open the same page using window.open script which i executed using RegisterStartupScript on Server side button click event (on which i am exporting data table to excel) and on page load i will check if export to excel button was clicked then execute the above mentioned code to render excel.

Nikhil Vaghela