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

Javascript in update panel

1 Answer 346 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ayesha
Top achievements
Rank 1
Ayesha asked on 09 Oct 2009, 02:14 AM
Hi,

I need to get my code working because it has to go live this monday. I've a big problem. My javascripts are not getting fired when put inside update Panel.

Pls  do not tell it's not telerik's problem. some ppl have responded to us like that.

This is my code:

 

//js function which isused to get refernce of the client object

 

 

 

 

 

<telerik:RadScriptBlock>
<script type="text/javascript">

 

 

 

 

 

function getSelected()

 

{

 

//get a reference to Radcombobox client object

 

 

 

 

 

 

var obTagCombo = document.getElementById("<%= 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 = document.getElementById("<%=m_radEmailEditor.ClientID%>");

 

 

 

//pasteHtml method is used to paste the contents passed to the editor control.

 

 

 

 

 

editor.pasteHtml(text);

}

 

 

 

</

 

script>

 

</

 

telerik:RadScriptBlock>

 

And I call this js getSelected () in

 

 

 


 

 

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

But I get a Js undefined: object expected error. Pls do help us in solving this bug. Pls help with code.

I'm sure you guys have a good solution for this.
Thanks,
ZR

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 14 Oct 2009, 12:17 PM
Hi Zaheka,

The following code works fine on my side:

<asp:UpdatePanel ID="UP1" runat="server">
    <ContentTemplate>
     
        <telerik:RadEditor id="m_radEmailEditor" runat="server">
            <ImageManager ViewPaths="~/" UploadPaths="~/" />
        </telerik:RadEditor>
         
         <telerik:RadComboBox ID="m_radTagCombo" runat="server">
             <Items>
                 <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1" />
                 <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" />
                 <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="RadComboBoxItem3" />
             </Items>
         </telerik:RadComboBox>
          
        <input type="button" value="Insert Tag" onclick="getSelected();" />
         
        <telerik:RadScriptBlock ID="RSB1" runat="server">
        <script type="text/javascript">
        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>
        </telerik:RadScriptBlock>
         
    </ContentTemplate>
</asp:UpdatePanel>

For your convenience I have attached my test project.

You should get a reference to RadEditor and RadCombobox objects using the MS AJAX $find() method as it demonstrated here.

Kind regards,
Rumen
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
Rumen
Telerik team
Share this question
or