Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.net gathering info when controls are clicked on

Posted on 2013-06-13
2
Medium Priority
?
195 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 2000 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:Murray Brown
ID: 39249598
Thanks very much
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 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