0

I am trying to concatinate some data in Razor to make a URL with a query string, along the lines of :-

<a href= "www.Mysite.com" + "?ID="+ @Html.Raw(m.intItemIdentifier) >  @Html.Raw(m.strItemHeadline) </a><br />

and yes I know RAW will bring back unencoded data, and I cannot alter the database.

1
  • You can't add strings together in an HTML tag.. Commented Sep 4, 2014 at 10:37

1 Answer 1

1

I guess the code you show is not rendering the URL you want.

Use either

<a href="http://www.example.com?ID=@(Html.Raw(m.intItemIdentifier))"> 

Or

<a href="@Html.Raw("http://www.example.com?ID=" + m.intItemIdentifier)"> 
Sign up to request clarification or add additional context in comments.

1 Comment

this works perfectly thanks, I didnt realise you didnt need to delimit the string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.