0

使用内联语法时,我无法正确显示“样式宽度”值。它呈现为:

风格=""

有什么建议么。

<table>
    <tr id="tr1" runat="server">
        <td style="width: <%= this.LabelColumnWidth %>">
            &nbsp;
        </td>
    </tr>
</table>
4

3 回答 3

1

内联尝试2:

试一试

<td style='<%# "width: " + this.LabelColumnWidth %>'>

想也许整个事情都需要在内联代码中。而不仅仅是宽度的值。

于 2012-07-18T17:26:33.740 回答
1

试一试

<td style="width: <%# this.LabelColumnWidth %>">

编辑:(现在我知道更多)

你为什么不添加一个id这样的td东西

 <td id="test" runat="server">

然后在代码后面做

 test.style = "width: 100px;" // or whatever
于 2012-07-18T17:00:49.960 回答
0

埃里克提出的答案几乎是正确的。只是,它应该有一个 = 而不是 #

<td style='<%= "width:" + this.LabelColumnWidth %>' > 

仅当您需要包含 eval() 或 bind() 函数时才使用哈希。否则,使用 = 符号。

于 2012-07-18T17:37:55.013 回答