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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -