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

evaluate js from control which is in string

2 Answers 79 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
Łukasz Kuryło
Top achievements
Rank 1
Łukasz Kuryło asked on 29 Apr 2010, 06:19 PM

Hi all.

Webservice renders a control and returns it in string. Using js when I paste it on the page, the javascript functions are not evaluated. How can I do that?

In Telerik XmlHttpPanel there is a EnableClientScriptEvaluation. How to do it without using this control?

2 Answers, 1 is accepted

Sort by
0
Łukasz Kuryło
Top achievements
Rank 1
answered on 30 Apr 2010, 01:18 AM

Maybe I start from beginning.

On the page I have several updatepanels. Depending on what I click in the menu, the proper updatepanel is filled with ascx control.

Now in one of this ascx control I need to have the posibility to change dynamically controls in one fieldset when I press the button.

If I place there another update panel, when I try to update him, the parent update panel fires to.

So now I have webservice which returns the content and paste it in the proper place on the place. Please tell me, with the code example if it is possible, how to evaluate the javascript in this situation?
0
Accepted
Pero
Telerik team
answered on 30 Apr 2010, 11:02 AM
Hello Ɓukasz,

I believe the client-side method you are looking for is $telerik.evalScripts(parentElement);. This method evaluates all the client scripts present in the parentElement. If you do not have any RadControls present on the page, the $telerik static library can be referenced in the <ScriptManager/> as shown in the following sample:

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
 
    <script type="text/javascript">
        function EvalScripts()
        {
            $telerik.evalScripts($get("divScripts"));
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <input type="button" value="EvalScripts" onclick="EvalScripts(); return false;" />
    <div id="divScripts">
 
        <script type="text/javascript">
            alert("Scripts are evaluated");
        </script>
 
    </div>
    </form>
</body>
</html>


Regards,
Pero
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
XmlHttpPanel
Asked by
Łukasz Kuryło
Top achievements
Rank 1
Answers by
Łukasz Kuryło
Top achievements
Rank 1
Pero
Telerik team
Share this question
or