這是人爲的,但它基本上是我在做什麼。我有一個一@helper像這樣:mvc razor @helper可以返回一個非編碼標籤嗎?
@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)
}
我得到的網頁上的輸出當然實際的字符串:
<img src='test1.png' />
而不是圖像。有沒有辦法阻止它從這種方式編碼?
完美。謝謝。 – kailoon