How to get child controls correct id to client side
I am working on ASP.NET and not using any 开发者_如何学JAVAASP.NET's AJAX framework.
Now I am trying to update the contents of the textboxes and dropdowns in the Grid controls cell on client side using (classic JavaScript way)AJAX. But problem I am facing is that controls (textbox, dropdown) which I would like to update when rendered on the client side get prefixed by the User Controls id and row ids. So it becomes like UserContro_row_no_controlId. With this it is becoming difficult to keep track of controls ids on the client side to update them.Please let me know how this can be simplified?
Can we get what exactly will be prefixed to control when it’s rendered on client side? What is good way to get ID to client side ? I have tried using control.clientId but it’s giving me only _controlId part not the UserContro_row_no part. Thanks all,If you want the id of a control in the same control/page you can do that this way:
<%=txtControl.ClientID%>
If you want the id of a control inside a usercontrol you can do that like this:
<%=userControl.FindControl("txtControl").ClientID%>
Where "txtControl" is the server id of the control and "userControl" is the server id of the usercontrol.
精彩评论