Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
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.
Posted 25-Sep-12 23:18pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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...
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 365
1 CPallini 335
2 BillWoodruff 324
3 George Jonsson 319
4 Gihan Liyanage 225
0 OriginalGriff 5,050
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,639
3 George Jonsson 2,911
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
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