MVC 后台调用JS

时间:2014-07-22 23:16:43   收藏:0   阅读:783

示例控制器:

        public ActionResult Index()
        {
            ViewBag.js = "<script type=‘text/javascript‘>alert(‘abc‘);</script>";
            return View();
        }

页面:

<html>
<head>
    <title>Demo</title>
</head>
<body>
    <div>
        @Html.Raw(ViewBag.js)
    </div>
</body>
</html>

就可以了

原文:http://www.cnblogs.com/hucaihao/p/3514143.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!