This is a migrated thread and some comments may be shown as answers.

[Solved] js undefined

1 Answer 119 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ayesha
Top achievements
Rank 1
Ayesha asked on 15 Sep 2009, 03:46 PM

hi,

I've a user control and the page that holds it has a Radscriptmgr.

I've the foll js fn:
 <script type="text/javascript">

    //js function which calls the makeUnselectable().
    function OnClientLoad(combobox, args)
    {
       makeUnselectable(combobox.get_element());
    }

    //Make all combobox items unselectable to prevent selection in editor being lost
    function makeUnselectable(element)
     {
       var nodes = element.getElementsByTagName('*');
       for (var index = 0; index < nodes.length; index++) {
          var elem = nodes[index];
          elem.setAttribute('unselectable', 'on');
       }
    }

    //js function which isused to get refernce of the client object
    function getSelected()
     {
       //get a reference to Radcombobox client object
       var obTagCombo = $find('<%=m_radTagCombo.ClientID %>');

       //get_value() returns the value of the control
       var value = obTagCombo.get_value();

       //get_text()returns the text of the control.
       var text = obTagCombo.get_text();

       //get a reference to RadEditor client object
       var editor = $find("<%=m_radEmailEditor.ClientID%>");

       //pasteHtml method is used to paste the contents passed to the editor control.
       editor.pasteHtml(text);
    }  
</script>

and i call it 

<input type="button" value="Insert Tag" onclick="getSelected();" />

and in radcombobox:   <telerik:RadComboBox ID="m_radTagCombo" OnClientLoad="OnClientLoad" runat="server">
                        </telerik:RadComboBox>

I need to select text from radcombo and click the insert btn and the selected text from radcombo gets pasted on to the radeditor.

Now, I get a "Microsoft JScript runtime error: 'OnClientLoad' is undefined"

Pls help me with code:

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 16 Sep 2009, 09:35 AM
Hi Zaheka,

I tried to reproduce the problem but unfortunately to no avail. Do you by any chance load teh control with AJAX? If so, note that the MS AJAX does not parse scripts as explained in the following blogpos and you should either workaround this or change your setup and impleemntation since this is general knowledge and it is not directly related to RadControls.

http://blogs.telerik.com/tervelpeykov/posts/08-10-20/ajax_using_ajax_to_load_a_usercontrol_that_has_javascript_declared_in_it.aspx

Kind regards,
Svetlina
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.
Tags
Editor
Asked by
Ayesha
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or