ASP.NET HyperLink dynamic parameters

Posted on 2007-08-02
Last Modified: 2013-11-07
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.
Question by:DerekWatling
    LVL 6

    Accepted 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


    Author Comment

    Thanks, that solved the problem.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now