Problem with DIV in ASP Components

Posted on 2004-11-12
Last Modified: 2012-05-05

I have a radio button with a div around it, as plain HTML it's fine but as soon as convert the HTML radion buttons into
ASP equivalents using RadioButtonList component the div  throws an error. How can I apply the div to the  RadioButtonList  without it throwing up errors?

Below is the ASP version throwing the error

<div id="checkgrouping" runat="server">
            <asp:RadioButtonList id="RadioButtonList1" runat="server">
                  <div id="checkgrouping" runat="server">
                  <asp:listitem id="webSearch" runat="server" value="Web Search"/>

When I run the application I get the following runtime error:

Parser Error Message: System.Web.UI.WebControls.ListItemCollection must have items of type 'System.Web.UI.WebControls.ListItem'. 'div' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

Any ideas ?
Question by:q2004
    LVL 20

    Expert Comment


    The page does not like the inner <div> inside the RadioButtonList control. You have to remove it. Any reason why you have such a tags?
    LVL 20

    Assisted Solution


    And also the asp:RadioButtonList close tag </asp:RadioButtonList> does not exists. The following tags should work.

                      <div id="checkgrouping" runat="server">
                            <asp:RadioButtonList id="RadioButtonList1" runat="server">
                                        <asp:listitem id="webSearch" runat="server" value="Web Search" />

    LVL 10

    Accepted Solution


    You don't really need the RadioButtonList you could just add a groupname then you can use your div

    <div id="checkgrouping" runat="server">

    <asp:RadioButton id="RadioButton1" GroupName="MyGroup"></asp:RadioButton>
    <asp:RadioButton id="RadioButton2" GroupName="MyGroup"></asp:RadioButton>
    <asp:RadioButton id="RadioButton3" GroupName="MyGroup"></asp:RadioButton>
    <asp:RadioButton id="RadioButton4" GroupName="MyGroup"></asp:RadioButton>




    Author Comment


    The RadioButtonList method worked, the inner div had to be taken out i.e. the div around the listitem.

    The second method; the RadioButton method worked fine but each RadioButton needs a Runat="Server" paramter so each one should read:

    <asp:RadioButton id="RadioButton1" GroupName="MyGroup" Runat="Server" ></asp:RadioButton>

    Enclosing the above in a div works fine.

    As for the inner div the html template was designed to me that way,  it needs to be there for correct display, so I'll be using the second method. Although I'm puzzled why a RadioButtonList refuses to accept an inner div.


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now