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

Does RadAjaxPanel Support RegisterStartupScript

1 Answer 197 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
test
Top achievements
Rank 1
test asked on 05 Aug 2009, 08:10 PM
I have a button inside a RadAjaxPanel, when the button is clicked. There is a server-side call. I want it to execute a Javascript function defined in the page by using RegisterStartupScript . However, it is not working. If I remove RadAjaxPanel or move the button beyond of the panel, it does work. The client code is just like following
 <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="LoadingPanel1"> <div id="app_layer" runat="server">  <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </div> </telerik:RadAjaxPanel<telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" />

Your help is appreciated.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Aug 2009, 10:53 AM
Hello,

I tried using the RegisterStartUpScript method as shown below to call a JavaScript on a button click, placed inside an AjaxPanel and it worked as expected. Check out the following code for any differences with your code:
js:
function test() 
   { 
    alert('button clicked'); 
   } 

c#:
protected void Button1_Click(object sender, EventArgs e) 
    {       
        ScriptManager.RegisterStartupScript(thisthis.GetType(), "script""test();"true);        
    } 

You can also use ResponseScripts aatribute of the AjaxPanel to achieve the same function:
c#:
protected void Button1_Click(object sender, EventArgs e) 
    {         
        RadAjaxPanel1.ResponseScripts.Add("func();"); 
    } 

Thanks
Princy.
Tags
Ajax
Asked by
test
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or