开发者

javascript views support for asp.net mvc 3

Is there any plugin or library that enables javascript views in asp.net mvc 3 such as the ones in rails where you put your javascrip开发者_JS百科t code in a view and then return it from the controller?


public ActionResult Foo()
{
    var model = ...
    Response.ContentType = "text/javascript";
    return View(model);
}

and in Foo.cshtml:

@model AppName.Models.SomeModel
@{
    Layout = null;
}
var someProperty = @Html.Raw(Json.Encode(Model.SomeProperty));
alert(someProperty);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜