【发布时间】:2013-09-07 18:57:12
【问题描述】:
这是我的页面 sn-p:
...
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table>
<tr>
<td>
<asp:TextBox MaxLength="255" ID="myTextBox" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</asp:Content>
...
这是页面代码隐藏部分:
...
Control parent = this.myTextBox.Parent; //this is acutally asp:Content control
string parentID = parent.ID; //this is PlaceHolderMain
...
我需要的是引用<td> 元素(因为我想更改它的Visibility 属性)。我怎样才能做到这一点?我哪里错得这么严重? :)
【问题讨论】:
-
你没有出错。你只是没有去:-)。看我的回答
-
我们可以不用服务器标签吗?因为我不能修改整个应用程序的网格。我需要将最后一个文本框添加到网格并对其应用一些 JS 代码,但有时网格会在
上应用 css 隐藏最后一个文本框。看到我需要检查它是否隐藏然后将JS应用到它。