ASP.NET Treeview控件无法处理数据中的尖括号(ASP.NET Treeview control failing to handle angle brackets in data)

编程入门 行业动态 更新时间:2024-10-25 09:38:33
ASP.NET Treeview控件无法处理数据中的尖括号(ASP.NET Treeview control failing to handle angle brackets in data)

我有一些数据包含一些字段中的尖括号。

即使正确转义为&lt:或> (甚至是十六进制代码),在Visual Studio 2005 ASP.Net中,字段数据在第一个尖括号处被截断。 如果我用花括号替换数据,它显示正常。

示例数据(未转义):

<ITReview><row TopNode="REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/><row TopNode="REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/></ITReview><ITReview><row TopNode="REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/><row TopNode="REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/></ITReview>

示例数据(转义):

<ITReview> <row TopNode="REQ 123456&#x09;TT Description&#x09;&lt;Date sent to app dev&gt;&#x09;&lt;Priority&gt;&#x09;&lt;SubTask Status&gt;"/> <row TopNode="REQ 456789&#x09;TT Description&#x09;&lt;Date sent to app dev&gt;&#x09;&lt;Priority&gt;&#x09;&lt;SubTask Status&gt;"/> </ITReview>

没有做任何棘手的事情,将TreeView绑定到设置了文件名的XMLDataSource,并将绑定指定为DataMember = row和TextField = TopNode。

我没有在网上找到任何东西,但当然搜索“尖括号”只会增加结果的数量,而不是减少它们。

有人看到这样的事吗? 了解变通方法或解决方案? ASP.Net v2.0.50727。

更新:我建议使用的CDATA示例。 没工作。

<ITReview> <TopNode> <MainData> <![CDATA[REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>]]> </MainData> </TopNode> <TopNode> <MainData> <![CDATA[REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>]]> </MainData> </TopNode> </ITReview>

I have some data which contains angle brackets in some of the fields.

Even if properly escaped as &lt: or &gt; (or even the hex codes), in Visual Studio 2005 ASP.Net, the field data is being truncated at the first angle bracket. If I replace the data with curly braces, it displayes fine.

Example Data (unescaped):

<ITReview><row TopNode="REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/><row TopNode="REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/></ITReview><ITReview><row TopNode="REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/><row TopNode="REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/></ITReview>

Example Data (escaped):

<ITReview> <row TopNode="REQ 123456&#x09;TT Description&#x09;&lt;Date sent to app dev&gt;&#x09;&lt;Priority&gt;&#x09;&lt;SubTask Status&gt;"/> <row TopNode="REQ 456789&#x09;TT Description&#x09;&lt;Date sent to app dev&gt;&#x09;&lt;Priority&gt;&#x09;&lt;SubTask Status&gt;"/> </ITReview>

Not doing anything tricky, binding the TreeView to an XMLDataSource with the file name set, and specifying the binding as DataMember=row and TextField=TopNode.

I didn't find anything online, but of course searching for "angle bracket" just increases the number of results, not decreases them.

Anyone see anything like this? Know of a workaround or solution? ASP.Net v2.0.50727.

Update: example of the CDATA I used, as suggested. Didn't work.

<ITReview> <TopNode> <MainData> <![CDATA[REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>]]> </MainData> </TopNode> <TopNode> <MainData> <![CDATA[REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>]]> </MainData> </TopNode> </ITReview>

最满意答案

如果我对尖括号进行双重编码,它似乎起作用,至少我认为你正在寻找。 所以&amp;lt; 而不是<

我四处寻找这种想法的原因可能会有一个你可以改变的设置。 看起来它来自XmlAttribute类的Value属性,但我没有看到关闭它的方法。

If I double encode the angle brackets, it appears to work, at least how I think you're looking for. So &amp;lt; instead of <

I poked around looking for the cause of this thinking there might be a setting you could change. It looks like it's coming from the Value property of the XmlAttribute class, but I don't see a way to turn it off.

更多推荐

本文发布于:2023-07-15 18:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117504.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:尖括号   控件   数据   Treeview   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!