Visual Studio 警告“内容不允许”在 ASP.NET 项目中

发布于 2024-08-26 14:56:00 字数 1020 浏览 2 评论 0原文

我上个月刚刚开始作为一名程序员工作,所以会有很多新手问题来自我,请继续关注...我现在正在修改提供的模板(来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七堇年 2024-09-02 14:56:00

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

<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>
一场信仰旅途 2024-09-02 14:56:00

尝试将标签配置从 更改

<ClientSideEvents property="value"></ClientSideEvents>

<ClientSideEvents property="value" />

Try changing the tag configuration from

<ClientSideEvents property="value"></ClientSideEvents>

to

<ClientSideEvents property="value" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文