Visual Studio Warning “Content is not allowed” in ASP.NET project

时光毁灭记忆、已成空白 提交于 2019-12-25 16:24:30

问题


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.


回答1:


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



回答2:


Try changing the tag configuration from

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

to

<ClientSideEvents property="value" />


来源:https://stackoverflow.com/questions/2511583/visual-studio-warning-content-is-not-allowed-in-asp-net-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!