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

2 Answers 2

21
<img src="@Url.Content(String.Format("~/Images/Model/{0}", item.ModelImagePath))"
Sign up to request clarification or add additional context in comments.

Comments

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"/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.