As one of the answers (minhpc_bk) also implied I had to go through the .aspx which uses the control to get the information I required. I use this function each time I wan't an id or so for one of the controls on the .ascx. function GetIdString() { var id = new String("<%= this.ClientID %>_"); return id; } Now I can easily do something like this in another function: document.getElementById(GetIdString()+"CheckBox1") Thanx everybody for the response... //LL
L
Lex Luthor
@Lex Luthor
Posts
-
Javascript in web user control -
Javascript in web user controlHello, Have anyone used javascript in an web user control(.ascx) (Visual Studion 2005, .NET Framework 2.0)? Alert works fine, but for example, I cant seem to get the ID of an asp checkbox. function CheckBoxChecked(id) { 1. alert(id); var elem = document.getElementById(id); var temp = document.getElementById('CheckBox1'); 2. alert(elem); 3. alert(temp); } results in: 1. Undefined 2. null 3. null I invoke the script as follows: asp:CheckBox ID="CheckBox1" runat="server" onclick="javascript:CheckBoxChecked()" (I have used javascripts with .ascx components before, though they were predifined by Telerik, which contols I were using at the time) //LL