Reputation: 2069
This is contrived, but its basically what I'm doing. I have an a @helper like so:
@helper MyImage(int i) {
String s = "<img src='{0}' />";
String theImage = "";
switch(i) {
case 0: theImage = "test1.png"; break;
case 1: theImage = "test2.png"; break;
default: theImage = "error.png"; break;
}
String r = String.Format(s, theImage);
@(r)
}
The output I get on the web page is of course the actual string:
<img src='test1.png' />
instead of the image. Is there a way to disable it from encoding it that way?
Upvotes: 9
Views: 4949
Reputation: 24729
http://msdn.microsoft.com/en-us/library/system.web.mvc.mvchtmlstring.aspx
@(new MvcHtmlString(r))
Upvotes: 2