c# - How to concatenate two strings in a <img> src tag? -
here want concatenate 2 strings inside <img>
tag. how this??
<img src=" "/partners" + @item.adpath" alt="" id="adimg" title="@item.adname" width:"50px" height="50px"/>
any suggestion?
you should able this:
<img src="/partners+@(item.adpath)" alt="" id="adimg" title="@item.adname" width:"50px" height="50px"/>
the razor engine replace @item.adpath
actual value, giving src="/partners+[value]"
.
since razor expression thing that's parsed, don't have try , work string concatenation logic tag - drop in razor expression want value appear.
edit: or, if don't want plus sign (not clear comments):
<img src="/partners@(item.adpath)" alt="" id="adimg" title="@item.adname" width:"50px" height="50px"/>
alternatively, try string.format
:
<img src="@string.format("/partners{0}", item.adpath)" alt="" id="adimg" title="@item.adname" width:"50px" height="50px"/>
Comments
Post a Comment