读书人

mvc3中ViewBag前台显示的有关问题

发布时间: 2012-12-17 09:31:40 作者: rapoo

mvc3中ViewBag前台显示的问题
前台页面


@section Head{
<script type="text/javascript">
alert@ViewBag.Test("");
</script>
}


后台

ViewBag.Test = "123";


打开页面查看源文件
显示的是:alert@ViewBag.Test("");
我想要的:alert123("");

希望老鸟帮帮我
[最优解释]
alert@(ViewBag.Test)("");
[其他解释]
改为
@section Head{
<script type="text/javascript">
alert'@ViewBag.Test'("");
</script>
}

[其他解释]
引用:
改为
@section Head{
<script type="text/javascript">
alert'@ViewBag.Test'("");
</script>
}


不行啊哥们
源文件查看是:alert'123'("");
[其他解释]
不太清楚你想要什么?
如果想输出到画面上就用 document.write('alert' + '@ViewBag.Test' + '("");');
如果想弹出对话框就要用 alert('@ViewBag.Test');
在javascript中如果想要使用ViewBag中的值,必须要加双引号或单引号才可以。

读书人网 >asp.net

热点推荐