c# - OnClick Event for Anchor Tags -
is there onclick
event anchor tags? have following line of code:
<li><a href="#" runat="server">logout</a></li>
when user clicks logout text want fire code in method this:
protected void btnlogout_click(object sender, eventargs e) { session.removeall(); session.abandon(); }
what best practice @ doing in anchor tag?
instead of standard html anchor tag, use linkbutton
this. provides functionality you're looking for.
here have sample
<asp:linkbutton id="btnlogout" text="logout" onclick="btnlogout_click" runat="server"/>
it renders html anchor visually it's same code.
Comments
Post a Comment