I have some .js code that generates the following anchor tag:
<a name="link_274_4" id="link_274" onserverclick="DownloadInspection_Click" runat="server">2017-09-10</a>
I cut and paste that out of the DOM Explorer of IE.
That link is not clickable on the page that I am displaying.
Here is the vb.net that I want it to run:
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
I would have expected the VB to need a Handles
Clause, but this SO post does not have it:
Running a code behind routine from an <a href
The anchor tags are generated in a table so I would not know what the code as the Handles clause.