我有一些 .js 代码生成以下锚标记:
<a name="link_274_4" id="link_274" onserverclick="DownloadInspection_Click" runat="server">2017-09-10</a>
我从 IE 的 DOM Explorer 中剪切并粘贴了它。
该链接在我显示的页面上不可单击。
这是我希望它运行的 vb.net:
Sub DownloadInspection_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim button As Button = DirectCast(sender, Button)
Dim pk As Integer = CInt(button.ID.Replace("link_", ""))
Dim FileNamePrefix As String = CStr(pk)
Dim PreApprovalDir = "C:\\Data"
Dim di As New DirectoryInfo(PreApprovalDir)
Dim fiArr As FileInfo() = di.GetFiles()
Dim fri As FileInfo
For Each fri In fiArr
If fri.Name.StartsWith(FileNamePrefix) Then
Exit For
End If
Next fri
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + fri.Name)
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Length", fri.Length)
Response.WriteFile(fri.FullName)
Response.End()
End Sub
我本来希望 VB 需要一个Handles
条款,但这个 SO 帖子没有它:从 https://stackoverflow.com/questions/7548129/running-a-code-behind-routine-from-an-a-href/7548147#7548147
锚标记是在表中生成的,因此我不知道 Handles 子句的代码是什么。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)