Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem with DIV in ASP Components

Posted on 2004-11-12
4
Medium Priority
?
1,111 Views
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"/>
            </div>
</div>

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 ?
0
Comment
Question by:q2004
  • 2
4 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 12568909

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?
0
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 360 total points
ID: 12568922

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" />
                        </asp:RadioButtonList>
                  </div>

                        
0
 
LVL 10

Accepted Solution

by:
lengreen earned 390 total points
ID: 12570259
Hi

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>

</div>


cheers

Len
0
 

Author Comment

by:q2004
ID: 12595186

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.

Thanks
Q
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

580 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