I want a person to click on purchase, which triggers code in the code-behind.
This works fine with a Button
, but I would prefer a text hyperlink?
<asp:Button runat="server" ID="purchase" Text="Purchase" />
How about a LinkButton? A LinkButton basically gives you an asp:Button styled as a hyperlink.
<asp:LinkButton runat="server" ID="purchase" Text="Purchase" />
See MSDN for more information.
Use a LinkButton instead of a Hyperlink control. It looks like a text hyperlink, but acts like a button.
Markup:
<asp:LinkButton runat="server" Text="Purchase" ID="purchase" />
In your code-behind
Private Sub purchase_ServerClick(sender As Object, e As System.EventArgs) Handles purchase.Click
'process order
End Sub
Markup:
<a runat="server" id="purchase">Purchase</a>
In your code-behind
Private Sub purchase_ServerClick(sender As Object, e As System.EventArgs) Handles purchase.ServerClick
'process order
End Sub
HtmlAnchor ServerClick Event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With