Visual Studio 警告“内容不允许”在 ASP.NET 项目中
我上个月刚刚开始作为一名程序员工作,所以会有很多新手问题来自我,请继续关注...我现在正在修改提供的模板(来自 DevExpress)以使用 ASP.NET 创建新的 Web 表单Visual Studio 2008 上的 2.0。
虽然该 Web 表单的功能已经存在,但我正在摆脱九十条警告消息,其中大多数来自提供的模板。
其中一个让我困惑了一段时间的是: “警告 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>
我自己看不出代码有什么问题,所以请在这里帮助我。
I am just started working as a programmer last month, so there will be plenty of newbie question come from me, stay tuned... I am now working on modify the provided template (from DevExpress) to create new web form using ASP.NET 2.0 on Visual Studio 2008.
While the functionality of that web form is there, I am in the process of get rid of ninety something warning message, most of them come from the provided template.
One of them puzzled me for a while is this one:
"Warning 75 Content is not allowed between the opening and closing tags for element 'ClientSideEvents'."
And here is the code:
<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>
I couldn't see anything wrong with the code myself, so please help me out here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Chetan Sastry 的回答是正确的,但他删除了。您放入 HTML 属性中的脚本未经过 HTML 编码。
您必须对 HTML 中具有特殊含义的任何字符进行编码,例如
<
、>
、&
和"
属性值的分隔符:Chetan Sastry was on the right track in his answer that he deleted. The script that you have put in the HTML attribute is not HTML encoded.
You have to encode any characters that have a special meaning in HTML, like
<
,>
,&
and the"
delimiters for the attribute value:尝试将标签配置从 更改
为
Try changing the tag configuration from
to