Click here to Skip to main content
12,831,243 members (49,222 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
Dear Friends,

Have a GOOD DAY !!

Am working on , 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.
Posted 26-Sep-12 0:18am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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());
isql="insert into your_table (yourfield) values (" + pval + ")";

Hope this helps...

Enjoy Coding...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100