How to concatenate two lines in an <img> src tag?
3 answers
You should just do this:
<img src="/partners+@(item.AdPath)" alt="" id="adimg"
title="@item.AdName" width:"50px" height="50px"/>
The Razor engine will replace @item.AdPaththe actual value by providing you src="/partners+[value]".
Since the Razor expression is the only one that is parsed, you do not need to try to use the string concatenation logic in the tag - just omit the Razor expression where you want the value to be displayed.
Edit: Or, if you don't need a plus sign (unclear from your comments):
<img src="/partners@(item.AdPath)" alt="" id="adimg"
title="@item.AdName" width:"50px" height="50px"/>
Alternatively you can try String.Format:
<img src="@String.Format("/partners{0}", item.AdPath)" alt="" id="adimg"
title="@item.AdName" width:"50px" height="50px"/>
+9