cgcmq
asked on
IIF is always evaluating true
I am trying to set the visibility of an asp.net tag to false, based on a condition, using IIF. The statement is always evaluating to true.
Visible='<%# IIF (1=2,false,true) %>'
The above code, when placed in a tag, is still visible even though the condition is clearly false. The complete tag is:
<asp:HyperLink ID="HyperLink1" runat="server" Text="[more]" NavigateUrl="~/exhibits/ch illing_out /en/more.a spx" Visible='<%# IIF (1=2,false,true) %>' />
What am I doing wrong?
Visible='<%# IIF (1=2,false,true) %>'
The above code, when placed in a tag, is still visible even though the condition is clearly false. The complete tag is:
<asp:HyperLink ID="HyperLink1" runat="server" Text="[more]" NavigateUrl="~/exhibits/ch
What am I doing wrong?
the expression use are using "1=2" is not a boolean expression
this may explain more.....
http://msdn.microsoft.com/en-us/library/27ydhh0d(VS.71).aspx
and
http://www.secretgeek.net/iif_function.asp
ASKER
Visible='<%# = IIF (1=2,false,true) %>' will not compile due to the leading = sign.
I am not sure why 1 = 2 would not be considered a boolean expression.
The links you refer to discuss the problems of using an IIF when there is a chance that either the true or false part of the statement cannot be executed such as is the case when dividing by 0. In my case, both true and false are valid values of the visibility attribute.
I am not sure why 1 = 2 would not be considered a boolean expression.
The links you refer to discuss the problems of using an IIF when there is a chance that either the true or false part of the statement cannot be executed such as is the case when dividing by 0. In my case, both true and false are valid values of the visibility attribute.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Visible='<%# = IIF (1=2,false,true) %>'
or
Visible='<% = IIF (1=2,false,true) %>'