Solved

ASP.net gathering info when controls are clicked on

Posted on 2013-06-13
2
188 Views
Last Modified: 2013-06-14
Hi

I want to record how many times people click on parts of my site.
What is the best way to record this and where do I store the information.
Also, is it possible to gather any information about the locality or anything else about the computer that the site is being clicked on
0
Comment
Question by:murbro
2 Comments
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 39247562
It's probably something like this:

'On markup, the link
  <asp:HyperLink ID="HyperLink1" runat="server" Target="_blank" NavigateURL='linkppage.aspx?theId=<%#"http://" + Eval("someID") %>'><%# Eval("WebsiteURL")%></asp:HyperLink>

Open in new window


'Then on codebehind

Protected Sub Page_Load(sender As Object, e As EventArgs)

	If Request.QueryString("theId") Is Nothing Then
	Else
		'initialize clicks
		Dim theId As String = Request.QueryString("theId").ToString()
		'* insert into the database here 

                Dim host As IPHostEntry
               'Get the server variable value. This gives you the PC where the user is clicking from.
                host = Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST"))
                Dim connStr As String = ConfigurationManager.ConnectionStrings("DBConnectionString").ConnectionString
                Dim conn As New SqlConnection(connStr)
                Dim s As String
		
	
                s = "INSERT INTO yourtable (clicks, userPC,dayofClicks) VALUES (@theId, @userPC,getdate())"
                Dim cmd = New SqlCommand(s, conn)
                cmd.Parameters.AddWithValue("@theId", theId)
                cmd.Parameters.AddWithValue("@userPC", host)
                conn.Open()
                cmd.ExecuteNonQuery()
                conn.Close()		
		
	End If

End Sub

Open in new window


Didn't test it but should get you very close to what you are looking for.
0
 

Author Closing Comment

by:murbro
ID: 39249598
Thanks very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now