Get Clientid Of A Control Placed Inside A Datacontrol
Can anyone help me to get the ClientID of a control which is kept in the ItemTemplate of an DataControl? My control is like this.
Solution 1:
something like this should work, if you assign it to an attribute of the CheckBox for example, or test it rendering it in the label of the CheckBox:
<asp:CheckBox ID="chkFlag" runat="server" AutoPostBack="true"
onClick="alert('<%# ((Control)Container).FindControl("chkFlag").ClientID %>')" />
P.S. I just copied from here, search in SO when opening new questions, or do we want to explode their SQL? :D
How do I find the Client ID of control within an ASP.NET GridView?
Solution 2:
in the ItemDataBound event handler... you can find the control and get the client id like this
((CheckBox)e.Item.FindControl("chkFlag")).ClientID
Post a Comment for "Get Clientid Of A Control Placed Inside A Datacontrol"