In what circumstances is it recommended to use the asp:HyperLink control?
I've come from a HTML background and am creating sites with ASP.NET and I tend to use raw HTML by default, whereas my colleagues use the asp: control versions.
In some cases that makes sense for the extra intellisense e.g. when creating <label>
, but for asp:Hyperlink, it seems more straightforward to enter the anchor tag directly.
The key benefit is that the Hyperlink is a control that can be programatically manipulated in the code-behind.
ASPX
<asp:HyperLink ID="hlLink" runat="server" />
ASPX.CS
hlLink.NavigateUrl = string.Format("~/SomeFolder/SomePage.aspx?SomeKey={0}", someKey);
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