Click to See Complete Forum and Search --> : Empty listbox and W3C compliance


JetDeveloper
October 10th, 2006, 12:04 AM
Hi,

I am trying to make my ASP.NET pages compliant with the W3C standards. Some of the pages have lists of items which can be initially empty. I am using asp:ListBox, which renders as a <SELECT>.

When I run it through the validator at http://validator.w3c.org, I get errors that the there needs to child elements between the <SELECT> and </SELECT> because the W3C standard does not allow a list box to be empty.

The only way I can think of getting around this is to insert a blank item ("") if there are no items selected, but users can still select this. This also causes problems when I want to transfer items between 2 listboxes, because I must remove the blank item before transferring any items over.

Is there any way to get around this or to extend XHTML to allow empty listboxes?

Thanks in advance

Alsvha
October 13th, 2006, 09:12 AM
Try inserting an empty value and then also disable the listbox so your users can't change it if only the empty value exists.