Search code examples
asp.netiif

Visual Studio : ASPX : corrupted 'IIf' syntax : strange error


The following declaration in my ASPX file contains an ERROR within the IIf() arguments...

<br /><asp:Label ID="lblvalLOF_IS_DUE"  runat="server" 
Text='<%# IIf((Eval("aIsLOF_Due") = "True"), "&#9745;", "&#9744;")%>'
style="font-size: 2em;"/>

The error that shows in the [Error-List] window is:

Argument not specified for parameter 'FalsePart' of 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.

There is a "squiggly" underline from IIF to the end-quote of #9745;" indicating that there is a syntax error within the IIf arguments.

I think there is some conflict with the declaration of the special-characters -- either QUOTEs or AMPERSAND or # symbol.

Any guidance will be appreciated. Thanks in advance.


Solution

  • OK friends...I simplified the aspx code and removed the server code as follows:

    <asp:Label ID="lblvalLOF_IS_DUE"  runat="server" 
    Text='<%# IIf((Eval("aIsLOF_Due") = "True"), "&#9745", "&#9744") & ";"  %>'
    style="font-size: 3em;"/>
    

    I returned to the original IIf() coding but separated the semi-colon from the values being returned by the IIf() with concatenating the semi-colon after the IIf(). This construct should also work if setting colors conditionally in the aspx code.