How to set the navigateurl property on a asp:hyperlink element

By Allen Stoner

Suppose you have a link like this, but want to change the navigateurl at run time. <asp:hyperlink id="idLink1" runat="server" CssClass="links" NavigateUrl="../link1.aspx">Link1</asp:hyperlink> You can't just do <asp:hyperlink id="idLink1" runat="server" CssClass="links" NavigateUrl="<%= GetURL('link1') %>">Link1</asp:hyperlink> You can remove the navigateurl property from the asp:hyperlink element and set it in the page_load. This will set the navigateurl property.

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    idLink1.NavigateUrl = GetURL("link1")
  End Sub

How to set the navigateurl property on a asp:hyperlink element  (1025 Views)