Search code examples
vb.netquery-stringanchorhref

use query string for href


Should be simple, but can't figure out how to do it.

Want:

<a href="/sites/folder/page.aspx?variable=123456">Test</a>

By:

<a href="/sites/folder/page.aspx?variable=<% Request.QueryString("variable1") %>">Test</a>

I've tried <%# and <%= not expecting either of them to work, but trying them out. Any ideas or pointers? Thanks.


Solution

  • maybe:

    <a href='/sites/folder/page.aspx?variable=<%= Request.QueryString("variable1") %>'>
    

    or (imo) use a protected or public property (is that the same in Vb?) in the code behind, then you can do:

    <a href="/sites/folder/page.aspx?variable=<%= Variable1 %>">
    

    which I think looks better, plus you can add logic in the code behind: does the value exist? set a default etc...