7

How to set image path dynamically for following:

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

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

Please guide me how to set the path dynamically in View.

And is there any Html helper tag to display image available in MVC RZOR?

Note: i have similar type of problem as described in

How to use/pass hidden field value in ActionLink

Community
  • 1
  • 1
Paul
  • 457
  • 2
  • 11
  • 26

2 Answers2

21
<img src="@Url.Content(String.Format("~/Images/Model/{0}", item.ModelImagePath))"
David Peden
  • 17,596
  • 6
  • 52
  • 72
1

If you have already saved the entire path into the table, follow it

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

or

<img src="@Url.Content(item.ModelImagePath)" style="width:100px;height:100px"/>
Pang
  • 9,564
  • 146
  • 81
  • 122