Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 12, 2012 01:58 AM by kenchi09
Dec 08, 2012 08:07 AM|LINK
I hope somebody could help me out in my problem with the recruitment application I am working on.
1. User selects an applicant from the gridview, and clicks the image button on the row corresponding to the applicant.
2. On the backend, web application creates a PDF using a template with the help of iTextSharp, then saves the file to a virtual directory (D:/).
3. Afterwards, the user should be able to download that PDF using a save dialog of some sort.
But I get exceptions like something related to Microsoft JScript and something like "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." while debugging.
Please help me out on this. I'm really having a hard time with the code snippet pertaining to Response.Write(), Response.Flush() Response.End(), etc.
Dec 08, 2012 10:04 AM|LINK
Hi... if ur transmitting a file to client as download untill server sending total data to client the process will takes place so u shouldn't call Response.End()... if u calls this method server will throw this error because the file transfer is in progress
but ur calling Response.End() method...
User the following code...
string DownloadedPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + gItem.Cells.Text.ToString();
FileInfo fi = new FileInfo(DownloadedPath);
long sz = fi.Length;
Response.ContentType = MimeType(Path.GetExtension(Path.GetExtension(DownloadedPath)));
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + System.IO.Path.GetFileName(DownloadedPath) + "\"");
we can user Response.Flush() method to send buffered data to client...
after completion of all ur work call ur
Dec 08, 2012 11:36 AM|LINK
I still get this kind of error when i used your code snippet:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
Dec 12, 2012 01:58 AM|LINK
I've solved this problem of mine. Thanks to your contributions as well.
The background of the problem that I forgot to indicate here was I was triggering a download event from a click to an image button in a gridview row of a gridview inside a Ajax Control Toolkit tab container.
Out of frustration, I just tried declaring the tab container as a post back trigger in the triggers of the update panel, and voila, the save as dialog appeared in the browser. And by the way, thanks to
chikkanti, I used his code snippet!