Question

I have button that opens a saveFileDialog to save a downloaded file to a clients PC.

After you save the file, or press cancel, the buttons on the web-part becomes unresponsive.

Why does this happen, and how can you fix it?

Code for webpart (I tried with javascript aswell, no success, still the same problem)

DataTable table = populateDataTable(selectQuery);

System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;

response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AppendHeader("content-disposition", "attachment;filename=EthicsFeedExport " + DateTime.Now.ToString("yyyy-MM-dd") + "s.cv");

StringBuilder sb = new StringBuilder(); \\populate sb

response.Write(sb.ToString());
response.Flush();
response.End();
Était-ce utile?

La solution 3

Our Main Programmer on site gave me the solution to this. Here it is. Just add this to your "onclick" event.

OnClientClick="window.setTimeout(function() { _spFormOnSubmitCalled = false; }, 10);"

Autres conseils

Ruan,

I had issues similar to what you are experiencing. For some reason SharePoint doesn't allow multiple Postbacks. Take a look at this link to another StackOverflow question No controls postback after using Export To CSV method .

Hope this helps.

I wrote an answer in another topic. Please try adding this javascript code to your webpart:

<script type='text/javascript'>
  _spOriginalFormAction = document.forms[0].action;
  _spSuppressFormOnSubmitWrapper = true;
</script> 

I guess this should help you with your problem. SharePoint seems to loose the original action of the form after the postback. If you set these variables you can reuse the form with its original action.

Here's the original thread: Generate a file for download on button click - without breaking other buttons

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top