Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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

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.
 
Share this answer
 
Hi,

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

C#
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...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900