Search code examples
c#htmlhyperlinkasp.netconcatenation

Concatenating a string in a querystring of a <a> link in c# created through asp.net


I can already send something in the querystring:

<a href='Exibe.aspx?var='lalala''>

but I'd like to send a string instead of lalala, and when i try to concatenate normally in the response.write with "+" signs, it just doesn't. it creates the url only with the part before the "+".

Facts:

  • the string has a value
  • I can concatenate it with other string and it works
  • I can use the querystring with something I write

Thank you

UPDATE: code that doesn't work:

responde.write("<a href='Exibe.aspx?nome='" + nome(0) + "''> click here </a>");

Code that works but doesn't do what I want (sends "VALUE" not my string)

responde.write("<a href='Exibe.aspx?nome='VALUE''> click here </a>");

I'm really new at this.. sorry


Solution

  • Are you looking for HttpUtility.UrlEncode or are you looking for something to build the Uri like UriBuilder ? Either way you should be able to google up some examples.