Detect click on a link

P

PL

Hi
I wanted to log a custom message when the user opens a link to a .pdf :

in the .aspx file:

<form runat="server">
....
<a href="file.pdf" OnServerClick="OnDownload" runat="server">link</a>
....
</form>

in the .vb :

Public Sub OnDownload(ByVal sender As Object, ByVal e As System.EventArgs)
Dim anchor As HtmlAnchor
' write special log
....
' open link
anchor=sender
Response.Redirect(anchor.HRef)
End Sub


It works (I have the log and the pdf is opened), but the problem is that by
this way I lose the real link. The link becomes
"javascript:__dopostback(...)" and so the user can't download the pdf file
with 'save as' menu action.
How can I do to let the link be 'file.pdf' and log with server code when the
user clicks it ?

Thanks for any Help

NL
 
G

Grant Merwitz

What i would do.

Create a general page that can stream PDF's to users.
Link the user directly to this page.

In the beginning of the page, you can do whatever processing you need.
You can also stream the pdf to the user.

That way, if they right click and Save Target As, they will still recieve
the pdf, and you can log what you want.

If you wanting to do this on the same page, i can't see it working without
JavaScript which is causing your problems

HTH and Good Luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top