计算点击的超链接并保存在数据库中 [英] Count Hyperlink clicked and save in database

查看:61
本文介绍了计算点击的超链接并保存在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

祝你有美好的一天!

正在使用Asp.net,C#和SqlServer2005.

我的要求是:

我的网页上有一个超链接(查看大学).

我需要计算此超链接的点击数.并且此计数必须存储在SqlDatabase表中.

请问有人可以帮我怎么做吗?

感谢ADVANCE.

Dear Friends,

Have a GOOD DAY !!

Am working on Asp.net , C# , SqlServer 2005.

My Requirement is :

I have a Hyperlink(View Colleges) on my Webpage.

I need to Count the number of Clicks for this hyperlink..and this counts must be stored in SqlDatabase Table.

Please can any one help me How to do this ?

Thanks in ADVANCE.

推荐答案



放置LinkBut​​ton而不是超链接,然后放置在链接按钮的click事件上,并放置以下代码...

Hi,

put LinkButton instead of hyperlink and then on link button''s click event put following code...

isql = "select max(yourfield) from your_table";
                    cmd = new SqlCommand(isql, con);
                    int pval = Convert.ToInt32(cmd.ExecuteScalar());
pval=pval+1;
isql="insert into your_table (yourfield) values (" + pval + ")";
cmd.ExecuteNonQuery();



希望这对您有帮助...

享受编码...



Hope this helps...

Enjoy Coding...


,您可以尝试使用jQuery AJAX异步调用网络服务(.asmx),该服务将包含一种更新数据库中点击次数的方法,并将继续正常的服务器端执行,可能是导航到您设置的NavigateUrl.
you can try using jQuery AJAX to asynchronously call a web service (.asmx) that will contain a method to update the click count in the database and will carry on the normal server side execution which probably would be the navigation to the NavigateUrl that you set.


这篇关于计算点击的超链接并保存在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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