0

我正在构建一个动态 ASP 表,每个单元格中都有 CheckBoxLists。根据内部情况,应禁用其中一些列表。它适用于 Chrome 和 FF,但不适用于 IE9。我已经逐步完成了禁用的代码,并且 Enabled 属性正确设置为 false,但它无法正确呈现给 IE。有人知道为什么吗?

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 );

内容面板在 ASPX 中如下所示,是标记中唯一的控件

<asp:Panel runat="server" ID="contentPanel" Height="450px" ></asp:Panel>

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>

铬的输出

<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>

请注意,这只是 ASP 面板的一部分,而不是整个网页

4

1 回答 1

2

不要设置属性 enabled=false,而是设置属性 disabled=disabled

li.Attributes.Add( "disabled", "disabled" );
于 2012-07-27T23:25:45.140 回答