evaluate js from control which is in string

3 posts, 1 answers
  1. Łukasz Kuryło
    Łukasz Kuryło avatar
    24 posts
    Member since:
    Jan 2010

    Posted 29 Apr 2010 Link to this post

    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. Łukasz Kuryło
    Łukasz Kuryło avatar
    24 posts
    Member since:
    Jan 2010

    Posted 29 Apr 2010 Link to this post

    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?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 30 Apr 2010 Link to this post

    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.
Back to Top