我有以下表格行:
<tr id="trInbox" runat="server" class="normal"
style='cursor:pointer; font-weight:<%# StyleBold(Convert.ToBoolean(Eval("inbRead")) ) %>'
onclick='selectedRow(this,<%# Eval("INBID") %>)'
onMouseOver="if(this.className!='selected') this.style.backgroundColor='#E2E1F4';"
onMouseOut="if(this.className!='selected') this.style.backgroundColor='#FFFFFF'">
但是,在我运行之后,我收到以下错误:
非法XML字符[打破此错误]
selectedRow(此,&lt;%#Eval(“INBID”)%&gt;)
你能告诉我我错过了什么语法吗?
答案 0 :(得分:1)
在运行元素服务器端时,最好在添加包含动态数据的属性值时使用String.Format()
。尝试:
<tr id="trInbox" runat="server" class="normal" style='<%# String.Format("cursor:pointer; font-weight:{0}", StyleBold(Convert.ToBoolean(Eval("inbRead")))) %>' onclick='<%# String.Format("selectedRow(this,{0})", Eval("INBID")) %>' onMouseOver="if(this.className!='selected') this.style.backgroundColor='#E2E1F4';" onMouseOut="if(this.className!='selected') this.style.backgroundColor='#FFFFFF'">
答案 1 :(得分:0)
也许你错过了一个“;”在backgroundColor风格,在onMouseOut。
答案 2 :(得分:0)
我想selectedRow方法会进行一些涉及对象(反)序列化或将Xml字符串转换为Xml文档的处理。
有些字符是非法的:http://www.w3.org/TR/REC-xml/#charsets
您应检查Xml字符串以删除任何无效字符。
以下是检查字符是否有效的实用方法示例:
public static bool IsValidCharForXml(char x)
{
return x == (char)0x9
|| x == (char)0xA
|| x == (char)0xD
|| (x >= (char)0x20 && x <= (char)0xD7FF)
|| (x >= (char)0xE000 && x <= (char)0xFFFD);
}