I have an UserControl and in it, a DropDownList. I’m using this code to add a disabled separator to the list of items:
ListItem separador1 = new ListItem(" -- -- -- -- -- ", "Separador");
separador1.Attributes.Add("disabled", "true");
this.ddlPais.Items.Add(separador1);
It works OK when the user control is displayed in a Page normally, but when it is located in a JQuery UI Dialog the separators items don’t have the enabled attribute and off course they are enabled.
Important Note: I managed to solve my problem while still typing the question in. I will post it anyway in case someone experience what I think is a jquery bug.
The solution was to add the disabled attribute after opening the JQuery Dialog.
$("#" + PanelClientId).dialog( "open" );
$("#" + PanelClientId).parent().appendTo(jQuery("form:first"));
$('option[value="Separador"]').attr('disabled','true'); //This is new in my code
I managed to fix it with a workaround. The solution was to add the disabled attribute in each pageLoad; it has to be the client side pageLoad to disable items after each async postback since I’m using UpdatePanel.