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

x
  • 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.
0
DerekWatling
Asked:
DerekWatling
1 Solution
 
apb2Commented:
Hi DerekWatling you can assign the navigate value in the onload event:
ie
 <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

apb2
0
 
DerekWatlingAuthor Commented:
Thanks, that solved the problem.
0

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