Doc文件不从asp.net中的UserControl下载
我有用户控件,其中包含一个包含候选数据的网格。 有一个列候选名称和模板字段链接按钮。 我附加了一个rowcommand事件,我正在下载一个word文件。 我有下载doc文件代码,它从简单的网页下载我的doc文件,但是这段代码不能用于用户控制。 任何人都可以帮我解决这个问题。 它提供错误响应不可用
Candidate Name <asp:LinkButton ID="lnkResume" CommandName="Download" CommandArgument='' runat="server" Text='' ToolTip=''> protected void grdCandidate_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Download") { byte[] Attachment = null; string Extension = string.Empty; string Resume = "Resume"; ClsCandidateManager objCandidateManager = new ClsCandidateManager(); ClsSecureManager objSecureManager = new ClsSecureManager(); Attachment = objCandidateManager.GetCandidateAttachment(Convert.ToInt32(e.CommandArgument), out Extension); if (Attachment != null && Attachment.Length > 0) { try { Response.Clear(); Response.Buffer = true; Response.Charset = ""; if (Extension == ".pdf") { Response.ContentType = "application/pdf"; } else { Response.ContentType = "application/vsd-msword"; } Response.AddHeader("content-disposition", "attachment;filename=" + Resume + Extension); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(Attachment); Response.Flush(); Response.End(); } catch (Exception ex) { string str = ex.Message + ex.InnerException; } } else { //ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "alert('Resume is not Uploaded !');"); } } } catch (Exception ex) { string str = ex.Message + ex.InnerException; }
使用UpdatePanel,如下所示,
- web.config asp.net中的oracle数据库连接
- 如何使用Simple Injector在ASP.NET HttpModule中正确地注入构造函数/属性
- 加载集线器时出错。 确保您的集线器引用正确,例如
- 动态创建按钮以调用方法并传入参数
- System.ObjectDisposedException:ObjectContext实例已被释放,不能再用于需要连接的操作
- .NET Web服务和BackgroundWorker线程
- ASP.NETdependency injectionHTTP模块(MS企业库)
- 如何在MVC Razor DropDownList中使用Html.Raw?
- 如何使用asp.net和c#从Web应用程序发送短信到手机?