I want to compare a boolean value from the Viewbag
in javascript. So at first I tried this:
if (@Viewbag.MyBoolValue)
do_sth();
But then I have error in console like: Value False/True is not declared
(not exactly).
So I tried this:
@{
string myBool = ((bool)Viewbag.MyBoolValue) ? "true" : "false";
}
and in javascript:
if (@myBool == "true")
do_sth();
But it does not work too. How can I make it work? Any help would be appreciated.