tags:

views:

21

answers:

2

Is it possible to have a server-side click handler for a hyperlink?

A: 

It sounds like you're after ASP.net Web Methods, there's an example here.

Basically, you decorate a method in your code-behind with the System.Web.Script.Services.ScriptMethod and System.Web.Script.Services.WebMethod attributes, which means that you can then call the method from javascript.

Rob
Now you've edited your question to clarify that you want a handler for a hyperlink, p.campbell's answer is more what you need =)
Rob
A: 

Consider converting your hyperlink, perhaps it's an <a> tag, to a ASP.NET server side control: LinkButton.

<asp:LinkButton runat="server" id="foo"   OnClick="LinkButton_Click" 
     Text="Do Some Stuff Server Side, and Expect a Redirect Somewhere" />

It's not clear from the question what you'd like to do server side. From here, you can call custom code and basically do anything once it's posted back.

p.campbell