Visual Studio:ASPX:损坏的'IIf'语法:奇怪的错误

时间:2021-09-25 02:51:44

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

我的ASPX文件中的以下声明在IIf()参数中包含ERROR ...

<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'.

没有为'Public Function IIf(Expression As Boolean,TruePart As Object,FalsePart As Object)As'参数'FalsePart'指定参数。

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

从IIF到#9745的结尾引用有一个“波浪形”下划线;“表示IIf参数中存在语法错误。

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

我认为与特殊字符的声明存在一些冲突 - 要么是QUOTE,要么是AMPERSAND或#符号。

Any guidance will be appreciated. Thanks in advance.

任何指导将不胜感激。提前致谢。

2 个解决方案

#1


0  

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

它似乎与特殊情况有关“&...;”在ASP内部解析VS.

Interesting that in C# i have error

有趣的是,在C#中我有错误

Error 1| Newline in constant

错误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#

和C#一样

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

#2


0  

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

好朋友......我简化了aspx代码并删除了服务器代码,如下所示:

<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.

我返回原始的IIf()编码,但是将分号与IIf()返回的值分开,并在IIf()之后连接分号。如果在aspx代码中有条件地设置颜色,则此构造也应该有效。

#1


0  

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

它似乎与特殊情况有关“&...;”在ASP内部解析VS.

Interesting that in C# i have error

有趣的是,在C#中我有错误

Error 1| Newline in constant

错误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#

和C#一样

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

#2


0  

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

好朋友......我简化了aspx代码并删除了服务器代码,如下所示:

<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.

我返回原始的IIf()编码,但是将分号与IIf()返回的值分开,并在IIf()之后连接分号。如果在aspx代码中有条件地设置颜色,则此构造也应该有效。