【发布时间】:2016-01-10 22:01:50
【问题描述】:
我正在尝试在一个单元格中制作一个带有 ImageButton 的表格。
我的表是这样实现的:
<table class="features-table">
<thead>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>1</td>
</tr>
</thead>
<tfoot>
</tfoot>
<tbody>
<div id="IDDIV" runat="server"></div>
</tbody></table>
我通过向 div 添加一个 html 字符串来填充我的表格。这个字符串是用这样的方法生成的:
private string buildHtmlTableString(List<Week> w)
{
string result = "";
foreach (Week element in w)
{
string s = "<tr>" +
"<td> Week " + element.weekNumber +
"</td>" +
"<td>" + element.1 + " €</td>" +
"<td>" + element.2 + " €</td>" +
"<td>" + element.3 + " €</td>" +
"<td>" + element.4 + "</td>" +
"<td>" + element.5 + " €</td>" +
"<td>" + element.6+ "</td>" +
"<td>" + element.7 +" €</td>" +
"<td>" + element.8 + "</td>" +
"<td>" + element.9 + " €</td>" +
"<td>" + element.10 + " €</td>" +
"<td>" + "<asp:ImageButton runat=\"server\" ID=\"" + element.1 + "\" Height=\"20px\" Width=\"20px\" OnClick=\"test_Click\" ImageUrl=\"~/detail.ico.ico\"></asp:ImageButton></td>" +
"</tr>";
result = result + s;
}
return result;
}
表格的样式:
#main
{
width: 960px;
margin: 160px auto 0 auto;
background: white;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
padding: 30px;
border: 1px solid #adaa9f;
-moz-box-shadow: 0 2px 2px #9c9c9c;
-webkit-box-shadow: 0 2px 2px #9c9c9c;
}
/*Features table------------------------------------------------------------*/
.features-table
{
width: 100%;
margin: 0 auto;
border-collapse: separate;
border-spacing: 0;
text-shadow: 0 1px 0 #fff;
color: #2a2a2a;
background: #fafafa;
background-image: -moz-linear-gradient(top, #fff, #eaeaea, #fff); /* Firefox 3.6 */
background-image: -webkit-gradient(linear,center bottom,center top,from(#fff),color-stop(0.5, #eaeaea),to(#fff));
}
.features-table td
{
border-right: 1px solid #cdcdcd;
height: 50px;
line-height: 50px;
padding: 0 20px;
border-bottom: 1px solid #cdcdcd;
box-shadow: 0 1px 0 white;
-moz-box-shadow: 0 1px 0 white;
-webkit-box-shadow: 0 1px 0 white;
white-space: nowrap;
text-align: center;
}
/*Body*/
.features-table tbody td
{
text-align: center;
font: normal 12px Verdana, Arial, Helvetica;
width: 150px;
}
.features-table tbody td:first-child
{
width: auto;
text-align: left;
}
.features-table td:nth-child(1)
{
background: #e7f3d4;
background: rgba(179,0,0,0.3);
}
/*Header*/
.features-table thead td
{
background: rgba(144,144,144,0.15);
font: bold 12px 'trebuchet MS', 'Lucida Sans', Arial;
-moz-border-radius-topright: 10px;
-moz-border-radius-topleft: 10px;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
border-top: 1px solid #eaeaea;
}
.features-table thead td:first-child
{
border-top: none;
}
/*Footer*/
.features-table tfoot td
{
font: bold 1.4em Georgia;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomleft: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom: 1px solid #dadada;
}
.features-table tfoot td:first-child
{
border-bottom: none;
}
我的问题是这些图像按钮未显示在表格中。如果我用 chrome 分析我的页面的 html 代码,我可以看到生成了标签,但是,我不知道为什么,我的按钮大小为 0px x 0px。也许你们中的任何人都知道该怎么做?
【问题讨论】:
标签: c# html asp.net html-table imagebutton