簡體   English   中英

SaveFileDialog使用C#禁用Sharepoint中的Webpart按鈕

[英]SaveFileDialog disables webpart buttons in Sharepoint using C#

我有一個按鈕,可以打開saveFileDialog來將下載的文件保存到客戶端PC。

保存文件或按“取消”后,Web部件上的按鈕將無響應。

為什么會發生這種情況,如何解決呢?

Webpart的代碼(我也嘗試過使用javascript,沒有成功,仍然是同樣的問題)

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();

我遇到了與您遇到的問題類似的問題。 由於某些原因,SharePoint不允許多次回發。 在使用“導出為CSV”方法后,請看此鏈接到另一個StackOverflow問題“ 無控件回發”的鏈接。

希望這可以幫助。

我在另一個主題中寫了一個答案。 請嘗試將此JavaScript代碼添加到您的Webpart中:

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

我想這應該可以幫助您解決問題。 在回發之后,SharePoint似乎失去了表單的原始操作。 如果設置這些變量,則可以以其原始操作重用該表單。

這是原始主題: 單擊按鈕時生成文件以供下載-不破壞其他按鈕

我們現場的主程序員為我提供了解決方案。 這里是。 只需將其添加到您的“ onclick”事件中即可。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM