简体   繁体   中英

Literal content ('</asp:RequiredFieldValidator>') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection'

I am facing the following error:

Literal content ('</asp:RequiredFieldValidator>') is not allowed within a 'System.Web.UI.WebControls.ListItemCollection' 

for the following code (inside the customer.ascx):

<div class="customerTableRow">
    <div class="customerTableLeftCol">
        <asp:Label ID="CustomerCountryLabel" runat="server" Text="Country:"></asp:Label>
    </div>
    <div class="customerTableRightCol">
        <asp:DropDownList ID="CustomerCountryDropDownList" runat="server">
            <asp:RequiredFieldValidator ID="CustomerCountryRequiredFieldValidator" ControlToValidate="CustomerCountryDropDownList" runat="server" ErrorMessage="RequiredFieldValidator">
            </asp:RequiredFieldValidator>
        </asp:DropDownList>
    </div>
</div>

Am I missing anything?

move RequiredFieldValidator out of DropDownList

<div class="customerTableRow">
    <div class="customerTableLeftCol">
        <asp:Label ID="CustomerCountryLabel" runat="server" Text="Country:"></asp:Label>
    </div>
    <div class="customerTableRightCol">
        <asp:DropDownList ID="CustomerCountryDropDownList" runat="server">
        </asp:DropDownList>


            <asp:RequiredFieldValidator ID="CustomerCountryRequiredFieldValidator" ControlToValidate="CustomerCountryDropDownList" runat="server" ErrorMessage="RequiredFieldValidator">
            </asp:RequiredFieldValidator>
    </div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM