Export to Excel and Navigating to other Page
-
Hi Guys , Stuck up in small issue can u any one please help me out of this. I have exported a excel report as below. But last statement is not executing. After downloading it i want to navigate to other page, But it is throwing exception. I understood that i am clearing the HTTP Response. But can i cal one more HTTP?? or how can i navigate to other page.. Please help on this string attachment = "attachment; filename=Export.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; GridView1.RenderControl(htw); Response.Write(sw.ToString()); Response.End() Response.Redirect("Downloaded.aspx",false); [Problem][Exception]
-
Hi Guys , Stuck up in small issue can u any one please help me out of this. I have exported a excel report as below. But last statement is not executing. After downloading it i want to navigate to other page, But it is throwing exception. I understood that i am clearing the HTTP Response. But can i cal one more HTTP?? or how can i navigate to other page.. Please help on this string attachment = "attachment; filename=Export.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; GridView1.RenderControl(htw); Response.Write(sw.ToString()); Response.End() Response.Redirect("Downloaded.aspx",false); [Problem][Exception]
Think about it. When you execute Response.End, that's it. There's nothing else being sent to the client. You cannot redirect a client after you call Response.End.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi Guys , Stuck up in small issue can u any one please help me out of this. I have exported a excel report as below. But last statement is not executing. After downloading it i want to navigate to other page, But it is throwing exception. I understood that i am clearing the HTTP Response. But can i cal one more HTTP?? or how can i navigate to other page.. Please help on this string attachment = "attachment; filename=Export.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; GridView1.RenderControl(htw); Response.Write(sw.ToString()); Response.End() Response.Redirect("Downloaded.aspx",false); [Problem][Exception]
Always wrap your code in "pre" tag.