首页 新闻 会员 周边

mvc3视图调用js的问题 路过的大侠看看吧

0
悬赏园豆:10 [已解决问题] 解决于 2012-08-18 11:46
 @if(viewbag.ShowMsg=="True") {
showalert();
}

<script type="text/javascript" >
function showalert()
{
alrer('我是弹出框');
}
</script >
接着就是在Controller中根据需要定义viewbag.ShowMsg的值了。

 

视图不就会提示上下文不存在showalert 请问这个要怎么改 大侠?

s_p的主页 s_p | 初学一级 | 园豆:138
提问于:2012-08-16 19:51
< >
分享
最佳答案
0
<script type="text/javascript">
 function showalert() {
         alert("1111");
     }
 
$(document).ready(function () {
 if ("@ViewData["ShowMsg"]" =="true") {
             showalert();
         }

});
</script 
收获园豆:10
@索卡 | 初学一级 |园豆:140 | 2012-08-16 21:29
ViewData["ShowMsg"] = "true";
@索卡 | 园豆:140 (初学一级) | 2012-08-16 21:30

@@索卡: 明白了 朋友谢谢

s_p | 园豆:138 (初学一级) | 2012-08-18 11:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册