C#:在更新面板中打开/保存对话 [英] C#: Open/Save Dialogue inside Update Panel
本文介绍了C#:在更新面板中打开/保存对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在asp.net的更新面板中使用过打开/保存对话框,但是由于以下代码行而无法正常工作:
I have used open/save dialog box inside update panel in asp.net but it is not working because of the code line:
Response.WriteFile(path);
我可以使用其他任何东西通过打开/保存对话框打开文件.
我打开文件的代码:
Can I use any thing else for opening a file through open/save dialog box.
My code for opening the file:
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("content-disposition","attachment; filename=" + name);
Response.ContentType = "Application/msword";
Response.WriteFile(path);
Response.Flush();
Response.Close();
Response.End();
推荐答案
您是要保存文件到客户端还是服务器?Response.WriteFile
不是您要使用的.尝试Response.TransmitFile
,但我不确定您是否真的需要/想调用Flush
,Close
或End
.
Are you trying to save a file to the client, or to the server?Response.WriteFile
isn''t what you want to use. TryResponse.TransmitFile
, and I''m not sure your really need/want to callFlush
,Close
, orEnd
.
您需要按钮来引起全部回发,而不是部分回发.即
You need the button to cause a full postback rather than a partial. i.e.
<Triggers>
<asp:PostBackTrigger ControlID="btnFileUpload"/>
</Triggers>
将此添加到您的page_Load()事件
Add this to your page_Load() Event
ScriptManager.GetCurrent(this).RegisterPostBackControl("Your Control id(want to open file dialogue when click)");
这篇关于C#:在更新面板中打开/保存对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文