gpt4 book ai didi

asp.net - ASP.NET 项目中的 Visual Studio 警告 "Content is not allowed"

转载 作者:行者123 更新时间:2023-12-02 20:40:19 25 4
gpt4 key购买 nike

我上个月刚刚开始作为一名程序员工作,所以会有很多新手问题来 self ,请继续关注...我现在正在修改提供的模板(来自 DevExpress)以使用以下命令创建新的 Web 表单Visual Studio 2008 上的 ASP.NET 2.0。

虽然该网络表单的功能已经存在,但我正在摆脱九十条警告消息,其中大多数来自提供的模板。

其中一个让我困惑了一段时间的是这个:“警告 75 元素“ClientSideEvents”的开始和结束标记之间不允许有内容。”

这是代码:

<dxe:ASPxListBox id="edtMultiResource" runat="server" width="100%" 
SelectionMode="CheckColumn" DataSource='<%# ResourceDataSource %>' Border-BorderWidth="0">
<ClientSideEvents SelectedIndexChanged="function(s, e) {
var resourceNames = new Array();
var items = s.GetSelectedItems();
var count = items.length;
if (count > 0) {
for(var i=0; i<count; i++)
_aspxArrayPush(resourceNames, items[i].text);
}
else
_aspxArrayPush(resourceNames, ddResource.cp_Caption_ResourceNone);
ddResource.SetValue(resourceNames.join(', '));
}"></ClientSideEvents>
</dxe:ASPxListBox>

我自己看不出代码有什么问题,所以请帮助我。

最佳答案

Chetan Sastry 的回答是正确的,但他删除了。您放入 HTML 属性中的脚本未经过 HTML 编码。

您必须对 HTML 中具有特殊含义的任何字符进行编码,例如 < , > , &"属性值的分隔符:

<dxe:ASPxListBox id="edtMultiResource" runat="server" width="100%" 
SelectionMode="CheckColumn" DataSource='<%# ResourceDataSource %>' Border-BorderWidth="0">
<ClientSideEvents SelectedIndexChanged="function(s, e) {
var resourceNames = new Array();
var items = s.GetSelectedItems();
var count = items.length;
if (count &gt; 0) {
for(var i=0; i&lt;count; i++)
_aspxArrayPush(resourceNames, items[i].text);
}
else
_aspxArrayPush(resourceNames, ddResource.cp_Caption_ResourceNone);
ddResource.SetValue(resourceNames.join(', '));
}"></ClientSideEvents>
</dxe:ASPxListBox>

关于asp.net - ASP.NET 项目中的 Visual Studio 警告 "Content is not allowed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2511583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com