如何在转发器控件中获取asp控件(_lblCouncils)的客户端ID?

时间:2014-03-18 15:31:43

标签: javascript asp.net

如何在转发器控件中获取asp控件(_lblCouncils)的客户端ID?

<ItemTemplate>
    <div id="NotificationDiv">
            <asp:Label ID="_lblRoleType" Text='<%#Eval("RoleType")%>' runat="server"></asp:Label>
            <asp:Label ID="_lblCouncils" Text='<%#Eval("CouncilData")%>' runat="server" onclick="Name(this)"></asp:Label>

    </div>
</ItemTemplate>

1 个答案:

答案 0 :(得分:2)

您必须处理OnRowDataBound(如果容器控件是GridView)或ItemDataBound事件(如果容器控件是Repeater),则找到控件:

<强> C#:

Labeb lbl = (Label)e.Item.FindControl("_lblRoleType");

<强> VB:

Dim lbl as Label = CType(e.Item.FindControl("_lblRoleType"),Label)