Solved

ASP.net gathering info when controls are clicked on

Posted on 2013-06-13
2
190 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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