using viewbag with jquery - asp.net mvc 3

后端 未结 3 1801
轮回少年
轮回少年 2020-12-28 21:38

I have a ViewBag.IsLocal set to true in controller. I would like to use jquery to check the ViewBag value and display an alert.

Code:

if(@ViewBag.IsL         


        
3条回答
  •  有刺的猬
    2020-12-28 22:14

    You can use the following function

    function parseBoolean(str)
    { 
       return /^true$/i.test(str);
    }
    

    and Use it as

    if(parseBoolean('@ViewBag.IsLocal') == true) 
    { 
       alert("yeah");
    }
    

提交回复
热议问题