FindControl on WebUserControl

3 posts, 0 answers
  1. Kyle Jones
    Kyle Jones avatar
    30 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post


    I am in a big hurry by my boss.  I need a way to find a control that is on a webusercontrol via javascript.  I have tried document.getelementbyid and $find('<% RadControl.ClientId %>') and nothing is working properly.  If anyone can get back to me really quick I would greatly appreciate it.

  2. Daniel
    Daniel avatar
    4949 posts

    Posted 02 Sep 2009 Link to this post

    Hello Kyle Jones,

    I suggest you try findControl/findElement methods

    $telerik.findControl(parentElement, ControlID); 

    var radGrid = $telerik.findControl(document"RadGrid1"); 

    or findElement
    $telerik.findElement(parentElement, ElementID); 

    var myCheckBox = $telerik.findElement(document"CheckBox1"); 

    Kind regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Charlie Crawford
    Charlie Crawford avatar
    9 posts
    Member since:
    Jun 2009

    Posted 03 Sep 2009 Link to this post

    if you need quick and dirty, you might try running the application and then viewing source when your user control is loaded. Inside the source file, you need to search for whatever id value you gave the control, for example, if you have a text box with an id="txtName", search the source for "txtName" and you should find a very long control ID value with "txtName at the end. It usually is something like:  'NameOfContainerPage_NameOfContainerControl_NameOfControl'. Sometimes the id value contains '$' or other symbol, but it is almost always the names of the parent containers separated with an underscore '_', followed by the name of the control.

    Once you have this value, you simply need to have a javascript line like:

    var txtName = document.getElementById("HostingPageName_UserControlName_txtName");  
    Be sure to test to see if the object was found or not:

    if (txtName) {  
      //Perform some action with 'txtName':  

    Hope this helps,

Back to Top