c# - MVC 4 - Razor - Pass a variable into a href url -


How can I pass a variable into a URL?

What I try is this, but this is not working. The URL only shows:

http://myurltest.com and not the full path

  @if (check1! = "D" ) {& Lt; Li & gt; & Lt; Div class = "a" & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Div class = "b" & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "http://myurltest.com/" + @ check1 + "/ go / 5 / true" & gt; & Lt; Div square = "c" & gt; & Lt; / Div & gt; & Lt; / A & gt; & Lt; / Li & gt; }    

like this:

  & lt ; A Href = '@ string.format ("http://myurltest.com/{0}/go/5/true", check1)' & gt;   

Rather than combining markup and code parts, the entire URL is included in the markup.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -