Reputation: 2689
I'm building a dynamic ASP table, with CheckBoxLists in each cell. Based on internal conditions, some of these lists should be disabled. It works in Chrome and FF, but not in IE9. I've stepped through the code that is doing the disabling, and the Enabled property is correctly set to false, but it doesn't render correctly to IE. Anyone have an idea why?
Table optionTBL = new Table();
optionTBL.ID = "optionTBL";
TableRow headerRow = new TableRow();
TableRow listRow = new TableRow();
listRow.VerticalAlign = VerticalAlign.Top;
foreach( string[] iss in issues )
{
// make a header
TableHeaderCell cell = new TableHeaderCell();
string headerTXT = "BLAH";
cell.Text = headerTXT;
cell.Width = Unit.Percentage( 33 );
cell.Height = Unit.Pixel( 1 );
cell.HorizontalAlign = HorizontalAlign.Center;
headerRow.Cells.Add( cell );
// put all the options in the radio list
CheckBoxList checkLST = new CheckBoxList();
checkLST.ID = "CKBLST" + iss[ 0 ];
while( condition )
{
// build the issue radios here
checkLST.Items.Add( new ListItem( "Text", "Value" ) );
}
foreach( ListItem li in checkLST.Items )
li.Attributes.Add( "theValue", li.Value );
// put the list in a cell in the row in the table
TableCell cell2 = new TableCell();
// some formatting
checkLST.BorderColor = System.Drawing.Color.Black;
checkLST.BorderStyle = BorderStyle.Solid;
checkLST.BorderWidth = 1;
checkLST.Width = Unit.Percentage( 100 );
// here we disable the check list if needed
if( needDisabled )
{
// disable the list, and check one
checkLST.Enabled = false;
checkLST.Items[ alreadySelected ].Selected = true;
}
// add the list in the cell
cell2.Controls.Add( checkLST );
cell2.Width = Unit.Percentage( 33 );
// put the cell in the row
listRow.Cells.Add( cell2 );
}
// put the table in the literal
optionTBL.Height = Unit.Percentage( 100 );
optionTBL.CellPadding = 5;
optionTBL.CssClass = "vote_table";
// here we have all the tables we need, stick em all in the literal on the page
contentPanel.Controls.Add( optionTBL );
content panel is in the ASPX as follows, and is the only control in the markup
<asp:Panel runat="server" ID="contentPanel" Height="450px" ></asp:Panel>
output from IE9
<div style="height: 450px;" id="contentPanel">
<table style="height: 100%;" id="optionTBL" class="vote_table" border="0" cellPadding="5">
<tbody><tr>
<th style="width: 33%; height: 1px;" align="center">ballot 1<br>Select 1<br></th><th style="width: 33%; height: 1px;" align="center">ballot 2<br>Select 1<br></th>
</tr><tr vAlign="top">
<td style="width: 33%;"><table style="border: 1px solid black; width: 100%;" id="CKBLST8"" border="0">
<tbody><tr>
<td><span theValue="29"><input id="CKBLST8_0" name="CKBLST8$0" type="checkbox"><label for="CKBLST8_0">Name A</label></span></td>
</tr><tr>
<td><span theValue="30"><input id="CKBLST8_1" name="CKBLST8$1" type="checkbox"><label for="CKBLST8_1">Name B</label></span></td>
</tr><tr>
<td><span theValue="0" WWW="1"><input id="CKBLST8_2" name="CKBLST8$2" type="checkbox"><label for="CKBLST8_2"><input id="writeIn82" value="Write In Candidate" type="text"></label></span></td>
</tr>
</tbody></table></td><td style="width: 33%;"><table style="border: 1px solid black; width: 100%;" id="CKBLST9"" border="0">
<tbody><tr>
<td><span theValue="31"><input id="CKBLST9_0" name="CKBLST9$0" type="checkbox"><label for="CKBLST9_0">Name 1</label></span></td>
</tr><tr>
<td><span theValue="33"><input id="CKBLST9_1" name="CKBLST9$1" type="checkbox"><label for="CKBLST9_1">Name 2</label></span></td>
</tr><tr>
<td><span theValue="0" WWW="1"><input id="CKBLST9_2" name="CKBLST9$2" type="checkbox"> <label for="CKBLST9_2"><input id="writeIn92" value="Write In Candidate" type="text"> </label></span></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
</div>
output from chrome
<div id="contentPanel" style="height:450px;">
<table id="optionTBL" class="vote_table" cellpadding="5" border="0" style="height:100%;">
<tbody><tr>
<th align="center" style="height:1px;width:33%;">ballot 1<br>Select 1<br></th><th align="center" style="height:1px;width:33%;">ballot 2<br>Select 1<br></th>
</tr><tr valign="top">
<td style="width:33%;"><table id="CKBLST8" disabled="disabled" border="0" style="border-color:Black;border-width:1px;border-style:Solid;width:100%;">
<tbody><tr>
<td><span disabled="disabled" thevalue="29"><input id="CKBLST8_0" type="checkbox" name="CKBLST8$0" checked="checked" disabled="disabled"><label for="CKBLST8_0">Name A</label></span></td>
</tr><tr>
<td><span disabled="disabled" thevalue="30"><input id="CKBLST8_1" type="checkbox" name="CKBLST8$1" disabled="disabled"><label for="CKBLST8_1">Name B</label></span></td>
</tr><tr>
<td><span disabled="disabled" thevalue="0"><input id="CKBLST8_2" type="checkbox" name="CKBLST8$2" disabled="disabled"><label for="CKBLST8_2"><input type="text" id="writeIn82" value="" disabled="disabled"></label></span></td>
</tr>
</tbody></table></td><td style="width:33%;"><table id="CKBLST9" disabled="disabled" border="0" style="border-color:Black;border-width:1px;border-style:Solid;width:100%;">
<tbody><tr>
<td><span disabled="disabled" thevalue="31"><input id="CKBLST9_0" type="checkbox" name="CKBLST9$0" checked="checked" disabled="disabled"><label for="CKBLST9_0">Name 1</label></span></td>
</tr><tr>
<td><span disabled="disabled" thevalue="33"><input id="CKBLST9_1" type="checkbox" name="CKBLST9$1" disabled="disabled"><label for="CKBLST9_1">Name 2</label></span></td>
</tr><tr>
<td><span disabled="disabled" thevalue="0"><input id="CKBLST9_2" type="checkbox" name="CKBLST9$2" disabled="disabled"><label for="CKBLST9_2"><input type="text" id="writeIn92" value="" disabled="disabled"></label></span></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
</div>
Note this only the portion of the ASP Panel, not the whole webpage
Upvotes: 0
Views: 4044
Reputation: 7539
Instead of setting the attribute enabled=false, set an attribute of disabled=disabled
li.Attributes.Add( "disabled", "disabled" );
Upvotes: 2