Having issues where in my .aspx page I pass in a boolean variable (C#) to a javascript function that is expecting a boolean type.
BUt the C# variable returns True, and javascript doesn't like the uppercase.
myjavascript( <%= MyBooleanVariableInCSharp %> );
If I convert the c# variable to string, then my javascript variable becomes a string and not a js bool value!
what is the solution to this nightmare? lol
Syntax to Declare Boolean Data Types in C: To declare a boolean data type in C we have to use a keyword named bool followed by a variable name. bool var_name; Here, bool is the keyword denoting the data-type and var_name is the variable name. A bool takes in real 1 bit, as we need only 2 different values(0 or 1).
By using '&' you can pass it by reference.
In C, Boolean is a data type that contains two types of values, i.e., 0 and 1. Basically, the bool type value represents two types of behavior, either true or false. Here, '0' represents false value, while '1' represents true value. In C Boolean, '0' is stored as 0, and another integer is stored as 1.
In C, boolean is known as bool data type. To use boolean, a header file stdbool. h must be included to use bool in C. bool is an alias to _Bool to avoid breaking existing C code which might be using bool as an identifier.
Try this:
myjavascript( <%= MyBooleanVariableInCSharp.ToString().ToLower() %> );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With