首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-12-17 
mvc3中ViewBag前台显示的问题前台页面@section Head{script typetext/javascriptalert@ViewBag.Test(

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中的值,必须要加双引号或单引号才可以。

热点排行