I'm tring to write a function that need to save a file (in csv) and has a condition. it's something like that:
If the file is small then 1MB then I want to pop up an alert in javascript and then continue with the save as file commands.
What I did was:
if(...)
{
}
else
{
ClientScript.RegisterStartupScriptBlock(...alert('aaa')...);
}
Response.ContentType = "text/csv";
Response.AppendHeader("Content-Disposition","attachment; filename=file.csv");
Response.TransmitFile("FILE.csv");
Response.End();
the save as works fine. but the alert wont popup in the else case.
I tried RegisterStartupScript
. I tried many options. But it seems that the response.end
is stops the clientscript from happening.
I am writing in c# asp.net (ajax enabled website, but not in use), visual studio 2005.
Can any one knows how can I bypass this? How can I make it work?
thank you, gadym.