Search code examples
asp.netanchorservercontrols

ASP.NET, Trigger codebehind eventhandler with anchor tag


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?


Solution

  • Use LinkButton for link with server side behaviour.

    <asp:LinkButton runat="server" 
      ID="LinkButton1" 
      OnClick="LinkButton1_Click" 
      Text="Link">
    </asp:LinkButton>