如何从asp.net控件获取<label>的完整ID

时间:2015-08-10 19:35:52

标签: c# asp.net accessibility

我正在尝试从asp.net控件中为<label>的{​​{1}}属性应用ID以获取辅助功能。出于某种原因,我无法获得.NET创建的完整ID。

ASPX页面上的HTML

for

呈现的内容是:

<td>
  <label id="lblSelReport" runat="server" for="selReport">Select Report Type</label>
  <asp:DropDownList ID="selReport" runat="server"></asp:DropDownList>
</td>

我认为<td> <label id="AxMstr_ExMstr_bodyPlaceHolder_bodyPlaceHolder_lblSelReport" for="selReport">Select Report Type</label> <select name="AxMstr$ExMstr$bodyPlaceHolder$bodyPlaceHolder$selReport" id="AxMstr_ExMstr_bodyPlaceHolder_bodyPlaceHolder_selReport"> ... </select> </td> 的{​​{1}}属性为for,因为我给它<label>控件的ID。显然,我做错了什么,但我不知道是什么。

有什么想法?谢谢!

1 个答案:

答案 0 :(得分:0)

服务器控件都具有'ClientID'属性,该属性解析为任何混乱的值.Net在运行时提供该控件。像这样:

<asp:Label ID="lblName" runat="server" />
<%= lblName.ClientID %>