如何跟踪锚块的点击? [英] How to track clicks on anchor block?

查看:89
本文介绍了如何跟踪锚块的点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另一个n00b ASP问题:
当客户端从href下载文件时,我想统计下载次数并捕获其他一些页面上的信息.因此,我需要触发一些事件,并执行常规的href类型下载代码.我不在乎事件是在下载之前还是之后触发的.看来,如果我在锚块中放置一个事件,则href会被忽略,反之亦然.

我怎样才能做到这一点? ASP和C#.

谢谢

Eric

Another n00b ASP question:
I want to count downloads and trap some other on-page information when clients download a file from a href. So I need to fire some event and also do the normal href type download code. I don''t care if the event fires before or after the download. It seems that if I put an event into the anchor block, the href is ignored and vice versa.

How can I do this? Asp and c#.

Thanks

Eric

推荐答案

您可以在超链接HyperLink1.Attributes.Add("onclick", "myAjaxFunction()");的click事件上附加一个javascript.在javascript或jQuery函数中,通过ajax(xmlHttp或jQuery)连接到服务器.服务器端功能将记录下载.由于超链接没有回发事件,也不必回发,因此您需要使用ajax.

此标记javascript事件触发器首先<a id="MainContent_HyperLink1" onclick="myAjaxFunction();" href="Test.jpg">HyperLink</a>然后下载.两者均可.
You can attach a javascript at the click event of the hyperlink HyperLink1.Attributes.Add("onclick", "myAjaxFunction()");. In the javascript or jQuery function connect to server through ajax (xmlHttp or jQuery). The server side function will record the download. As hyperlink don''t have postback events and don''t have to post back you need to use ajax for this.

<a id="MainContent_HyperLink1" onclick="myAjaxFunction();" href="Test.jpg">HyperLink</a> for this markup javascript event trigger first then the download. Both works.


http://stackoverflow.com/Questions/2496583/asp-net-count-download-clicks [ ^ ]

希望以上信息对您有所帮助.如果您还有其他顾虑,请告诉我.
http://stackoverflow.com/questions/2496583/asp-net-count-download-clicks[^]

I hope the above information will be helpful. If you have more concerns, please let me know.


这篇关于如何跟踪锚块的点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆