tags:

views:

35

answers:

2

hi actually i want to store value that has been clicked by user on web page for instance.

suppose this is my web page content of list

**

**google.com**
**yahoo.com**
**facebook login**
**stackoverflow.com**

**

now suppose user click on facebook login 

then how to know that user has clicked on facebook login actually i want to keep record for further processing.

+3  A: 

Client-side way:

Before finish the page render, add programmatically onclick event to each hyperlink, call on click an async JavaScript script to record url

Server-side way: (extending @Justin's answer)

<asp:LinkButton runat="server" OnClick="urlGoogle_Click">google.com</asp:LinkButton>

protected void urlGoogle_Click(object sender, EventArgs e)
{
    DataBase.Record("google.com");
    this.Response.Redirect("http://google.com");
}
abatishchev
Beat me. You'd need a web handler (web service method?) to handle the AJAX call to store the data.
Paul Hadfield
+4  A: 

Abatischev's suggestion will work, but there's an easier method that doesn't involve making AJAX calls if you don't want to go through the hassle.

Instead of having the link go directly to the page that you're linking to, you should have it submit to your asp.net page. You can then record the click there before redirecting to the destination page.

Justin Niessner
actually what code i have to write for tracing onclick event...
Nishant
You would convert the hyperlinks into LinkButton controls. LinkButton controls postback to the page that they are on. In Page C#/VB.NET code you would implement a methods that handle the LinkButtons' server side "click" events. In these methods, you would record which link was clicked on and then call the Response.Redirect(url, true) method to redirect the user to the page that they wanted to go to.
Frinavale
o6tech