How to set image path dynamically in MVC 3 RAZOR

How to set the image path dynamically for the following:

<img src="/Images/Model" + @item.ModelImagePath />

"/ Images / Model" this path is fixed, the rest of the path comes from the column [ ModelImagePath ] Model DBTable.

Please indicate how to dynamically set the path in the view.

And is there an HTML helper tag for displaying an image available in MVC RZOR?

Note. I have a similar type of problem described in

How to use / pass hidden field value in ActionLink

+5
source share
2 answers
<img src="@Url.Content(String.Format("~/Images/Model/{0}", item.ModelImagePath))"
+19
source

If you already saved the entire path in the table, execute it

<img src="@Url.Content(String.Format("{0}",item.ModelImagePath))"/>

or

<img src="@Url.Content(item.ModelImagePath)" style="width:100px;height:100px"/>
0

All Articles