Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3448
  • Last Modified:

ASP.NET HyperLink dynamic parameters

How does one specify dynamic parameters on a HyperLink control? My link needs to pick up a value from the QueryString to include in it's own QueryString.

When I try

  <asp:HyperLink ID="hlUsage" runat="server" NavigateUrl='<%# "~/Admin/AgentUsage?id=" & Request.QueryString("id") %>'>View usage...</asp:HyperLink>

the anchor tag that is emitted is missing the href attribute.
1 Solution
Hi DerekWatling you can assign the navigate value in the onload event:
 <asp:HyperLink ID="hlUsage" runat="server"> View usage...</asp:HyperLink>

Behind code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim _ID As String = Request.QueryString("id")
hlUsage.NavigateUrl = Page.ResolveURL("~/Admin/AgentUsage?id=" & _ID)
End If

End Sub

Hope that helps

DerekWatlingAuthor Commented:
Thanks, that solved the problem.

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now