views:

554

answers:

3

Is it possible to call an eventhandler codebehind, using an anchor tag? I've tried different things, but it doesn't seem to work.

I've tried writing my tag like this:

<a class="Button" onclick="Button1_Click" runat="server"></a>

with no success...

Any ideas?

+1  A: 

Use LinkButton for link with server side behaviour.

<asp:LinkButton runat="server" 
  ID="LinkButton1" 
  OnClick="LinkButton1_Click" 
  Text="Link">
</asp:LinkButton>
Canavar
Yep, linkbutton is the way to go...
Soeren
+1  A: 

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.aspx

<asp:LinkButton ID="Button1" OnClick="Button1_Click" runat="server" 
     CssClass="Button" Text="Click Me" />
Scott Ivey
A: 

You can use the ServerClick event for handling server side clicks for an anchor tag..

Halil K