Solved

ASP.net gathering info when controls are clicked on

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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