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?

Answers


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>

Need Your Help

WPF - C#: This element is not currently associated with any context

c# .net wpf resourcedictionary elementhost

I have a WPF UserControl, which I use in a WinForms Control within an ElementHostControl. Then I start a WPF Window, while the Windows Form is still open. If I then close the WPF Window, and try to...

Launching 32 bit executable from command prompt in Win 7 64 bit OS

windows-7 command-prompt syswow64

I am working on Windows 7 64 bit and have a wierd problem. I installed installAnywhere(a 32 bit application) in c:\Programs(x86) since I did not want to install it in the regular "c:\Program Files(...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.