2

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.

John D
  • 517
  • 7
  • 22
  • Looks good at a first glance. Let's start small - try just to remove ampersand and hash symbol and see if that works. It won't output exactly what you need, but will give some troubleshooting info – Andrei Aug 14 '15 at 14:41
  • Agreed, I think the # symbol is to blame.. – Oliver Gray Aug 14 '15 at 15:16
  • 1
    remove `;` seems in vb it some special, it interesting but if you run this as is you get correct work, seems error in vs – Grundy Aug 14 '15 at 15:24
  • Removing did the trick -- thanks a million. – John D Aug 14 '15 at 15:43
  • This was the answer. Thanks Grundy. – John D Aug 14 '15 at 15:44
  • @JohnD, but i don't know **why** it did the trick :-D also seems like something with vs parsing if it work with semicolon when you move it to code behind – Grundy Aug 14 '15 at 15:44

2 Answers2

0

It seems it is related to special cases "&...;" in aspx parsing inside VS.

Interesting that in C# i have error

Error 1| Newline in constant

and this also fixed after removing semicolon, so this working sample

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

and same for C#

<asp:Label ID="lblvalLOF_IS_DUE"  runat="server" Text='<%# ((Eval("aIsLOF_Due") = "True")? "&#9745": "&#9744")%>' style="font-size: 2em;"/>
Grundy
  • 13,356
  • 3
  • 35
  • 55
0

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.

John D
  • 517
  • 7
  • 22