Solved

ASP.net gathering info when controls are clicked on

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

22 Experts available now in Live!

Get 1:1 Help Now