Ryan
Ryan

Reputation: 5506

how to write <img> tag when MVC3 thinks .jpg is a property

I need to write

<img src="/view/pano/@img.ImageName/@img.ImageName.jpg"

But the problem is that MVC3 thinks .jpg is a property of ImageName. How can I tell it that this is just clear text?

Upvotes: 1

Views: 908

Answers (1)

tvanfosson
tvanfosson

Reputation: 532765

@{
    var src = string.Format( "/view/pano/{0}/{0}.jpg", img.ImageName );
}

<img src="@src" alt="..." /> 

or you could move the construction of the string inline, but I find that less readable.

<img src="@string.Format( "/view/pano/{0}/{0}.jpg", img.ImageName )" alt="..." />

Upvotes: 3

Related Questions