1

Not sure if I'm asking this right, but I have this:

<a href="mypage.aspx?id=<% Request.QueryString["id"].ToString(); %>&sec=map">
    Map
</a>

But it doesn't add the ID to the url query string. Not sure what to do cause I really don't want to have to make a bunch of literals to build this on code side.

The url I get is:

mypage.aspx?id=&sec=map
4
  • What is the url it sends you to? Commented Aug 22, 2014 at 16:21
  • just edited with the url it gives me, basically the "id" query string is blank Commented Aug 22, 2014 at 16:24
  • Can you put a breakpoint in that section, see what the method returns? Commented Aug 22, 2014 at 16:24
  • First, try the easiest, replace the double-quotes of href by single-quotes. Commented Aug 22, 2014 at 16:28

1 Answer 1

5

You need an = after the <% otherwise the value is not written out. You will then need to remove the semi-colon as well:

<a href="mypage.aspx?id=<%= Request.QueryString["id"].ToString() %>&sec=map">
    Map
</a>

See this question for more details on the various meanings of <%.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.