0
動態HTML內容在我的.Net MVC 3應用程序頁面,我需要做此功能: 當按鈕用戶點擊,它應該navagate他到一些網頁,但與HTML內容,我在模型屬性。可能嗎?顯示視圖從模型屬性
動態HTML內容在我的.Net MVC 3應用程序頁面,我需要做此功能: 當按鈕用戶點擊,它應該navagate他到一些網頁,但與HTML內容,我在模型屬性。可能嗎?顯示視圖從模型屬性
當然,在視圖中:
@model MyViewModel
@{
Layout = null;
}
@Html.Raw(Model.SomePropertyThatContainsHtml)
但是,這是完全荒謬的,你寧願有你的控制器動作直接返回ContentResult
:
public ActionResult SomeAction()
{
MyViewModel model = ...
return Content(model.SomePropertyThatContainsHtml, "text/html");
}
是的,這是可能的。 這一新的觀點使用
@Model YourModel
@{
Layout = null;
}
@Html.Raw(Model.Propery)
感謝,那麼請使用建議我創建新視圖,並在其上添加一些動態內容?在這個視圖中,它只是我需要的代碼? – revolutionkpi
更新我的答案。 –