【发布时间】:2017-04-11 23:25:20
【问题描述】:
在 asp:LinkButton 点击事件中执行 response.appendheader content-disposition 后,更改背后的代码会丢失。
我有一个 asp:LinkButton,当用户点击时,附件将被下载,我还需要知道链接是否被点击。 出于测试目的,我放置了一个文本框并在 asp:LinkButton 单击事件上更改了它的文本。 但文本框文本仍然是旧文本并且文件正在正确下载。
<asp:LinkButton runat="server" ID="LinkAttachmentView"
ToolTip="Click here to Download the Attachment" Font-Bold="True"
ForeColor="Red" >Click here to View the Attachment
</asp:LinkButton>
这里是代码
Protected Sub LinkAttachmentView_Click(sender As Object, e As System.EventArgs) Handles LinkAttachmentView.Click
If HdAttachmentFileName.Value = "" Then
HdAttachmentClicked.Value = "0"
Return
End If
HdAttachmentClicked.Value = "1"
TextBox1.Text = "clicked"
Response.ContentType = ContentType
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(HdAttachmentFileName.Value))
Response.WriteFile(HdAttachmentFileName.Value)
Response.Flush()
Response.End()
HdAttachmentClicked.Value = "1"
TextBox1.Text = "clicked"
End Sub
【问题讨论】:
标签: asp.net