I have the following image which is rendered this way.
<img src="../../../..@Model.FloorPlan.Floor_Plan_Image_Path@Model.FloorPlan.Floor_Plan_Image_Filename" alt=""/>
I want if possible it's src attribute will be changed into Url.Content.
What I have tried is this but my problem is it treats my model as string:
<img src="@Url.Content("~/Model.FloorPlan.Floor_Plan_Image_Path@Model.FloorPlan.Floor_Plan_Image_Filename")" alt=""/>
Can anyone help me?
The value of the Path and Filename is as follows:
Model.FloorPlan.Floor_Plan_Image_Path = "/Content/Uploads/FloorPlans/00004601/" Model.FloorPlan.Floor_Plan_Image_Filename = "testfloorplan.png"
I think I understand what you're going for. Try this:
Try
I found myself in a situation where I would need to format the string almost on any view, so I made an extension method for this, just to get rid of those
String.Format
's on every View.It just simply formats the specified path, nothing much going on, however calling it would be a bit nicer to read.