0

각 셀의 CheckBoxLists를 사용하여 동적 ASP 테이블을 작성합니다. 내부 조건에 따라 이러한 목록 중 일부는 사용할 수 없도록 설정해야합니다. Chrome 및 FF에서는 작동하지만 IE9에서는 작동하지 않습니다. 사용하지 않는 코드를 통해 밟았으며 Enabled 속성이 false로 올바르게 설정되었지만 IE에 올바르게 렌더링되지 않습니다. 누구나 왜 그런 생각이 들까?ASP .NET을 사용하지 않도록 설정 CheckBoxList

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이며, 마크 업에서 유일한 제어를

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

출력 크롬에서 IE9에서

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

출력이다

<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의 부분에만 유의하십시오. 패널이 아닌 전체 웹 페이지

+0

당신은 또한 IE9에서 렌더링 된 HTML을 표시 할 수 있습니다 장애인 = 장애인의 속성을 설정 = false를 활성화? –

+0

이것은 다소 이상합니다. 크롬 html은 문제없이 IE9 (또는 FF)에서 작동합니다. 그렇다면 왜 IE 용으로 깨진 것입니까? 'disabled = "disabled"가 생략 된 이유는 무엇입니까? –

답변

2

대신 속성을 설정은

li.Attributes.Add("disabled", "disabled"); 
+0

그게 효과가있다. 또한 checked = 'checked'속성을 추가해야했습니다. 또한이 방법은 Chrome에서 올바르게 표시되지 않았습니다. 그래서 내 원래의 코드를 모두 사용하고이 속성 방법은 양쪽 모두에서 올바르게 표시됩니다. 비록 내가 아직도 이유가 확실하지 않지만 적어도 지금은 작동 중이다. 도와 주셔서 감사합니다! – CDspace

관련 문제