register script on AJAX postback

3 posts, 0 answers
  1. robertgalvinjr
    robertgalvinjr avatar
    36 posts
    Member since:
    Jun 2006

    Posted 30 Dec 2009 Link to this post

    On my .ASPX page I have:
    <head id="Head1" runat="server">     
        <script type="text/javascript" src="swfobject.js"></script>     
        <form id="form1" runat="server">     
           <telerik:RadScriptManager ID="RadScriptManager1" runat="server">     
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"  LoadingPanelID="RadAjaxLoadingPanel1">     
      <asp:ImageButton ID="btnPrev" runat="server" onclick="btnPrev_Click"  ImageUrl="images/btnPrev.png"/>  
    <asp:ImageButton ID="btnNext" runat="server" onclick="btnNext_Click" ImageUrl="images/btnNext.png"/></td>  
    <div id="flashContent">     
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">     

    When I click the IMageButtons I need the scriptmanager to execute a javascript function that is in the swfobject.js file. I can get this to happen on the Page_Load (below) but not on the button clicks. What do I need to do to fire off a javascript function on AJAX postbacks?

    sSWF += @"<script type=""text/javascript"">";  
            sSWF += @"var flashvars = false;";  
            sSWF += @"var params = { menu: ""false"", flashvars: ""FMSServerURL=" +  
                sServer + "&sID=" + sStreamID +  
                "&imgURL=" + imageURL + @""" };";  
            sSWF += @"   var attributes = { id: ""myDynamicContent"", name: ""myDynamicContent"" };";  
            sSWF += @"swfobject.embedSWF(""presoViewer.swf"", ""flashContent"", """ + swfWidth + @""", """ + swfHeight + @""", ""9.0.0"", """", flashvars, params, attributes);";  
            sSWF += "</script>";  
                    Type cstype = this.GetType();  
            ClientScriptManager cs = Page.ClientScript;  
                 cs.RegisterStartupScript(cstype, "SWFScript", sSWF, false);  
  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 04 Jan 2010 Link to this post

    Hello robertgalvinjr,

    Please use the following code to register the script:


    This should be enough to execute the script after the ajax request.

    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. DevCraft R3 2016 release webinar banner
  4. Jeroen Speldekamp
    Jeroen Speldekamp avatar
    30 posts
    Member since:
    Mar 2005

    Posted 14 Jan 2010 Link to this post

    Try to do this in your page load function

    Remove this line
    ClientScriptManager cs = Page.ClientScript;

    Replace this line
    cs.RegisterStartupScript(cstype, "SWFScript", sSWF, false);

    by this
    RadScriptManager.RegisterStartupScript(this, this.GetType(), "SWFScript", sSWF, false);
Back to Top