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

register script on AJAX postback

2 Answers 325 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
robertgalvinjr
Top achievements
Rank 1
robertgalvinjr asked on 30 Dec 2009, 04:40 PM
On my .ASPX page I have:
<head id="Head1" runat="server">     
    <title></title>     
    <script type="text/javascript" src="swfobject.js"></script>     
</head>     
<body>     
    <form id="form1" runat="server">     
    <div>     
             
       <telerik:RadScriptManager ID="RadScriptManager1" runat="server">     
        </telerik:RadScriptManager>     
        <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">     
                                 
                            </div>     
  </telerik:RadAjaxPanel>     
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">     
        </telerik:RadAjaxLoadingPanel>     
 

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 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 04 Jan 2010, 02:51 PM
Hello robertgalvinjr,

Please use the following code to register the script:

RadAjaxPanel1.ResponseScripts.Add(sSWF)

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

Greetings,
Veskoni
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.
0
Suneco
Top achievements
Rank 2
answered on 14 Jan 2010, 10:26 AM
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);
Tags
ScriptManager and StyleSheetManager
Asked by
robertgalvinjr
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Suneco
Top achievements
Rank 2
Share this question
or