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

radalert from codebehing not firing first time

1 Answer 108 Views
Window
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 19 Feb 2009, 06:55 PM
I am having trouble getting radalert to fire the first time when following the example posted here:

http://www.telerik.com/support/kb/aspnet-ajax/window/calling-radalert-from-codebehind-all-versions-of-radwindow.aspx

I am using the last example:
3. Calling radalert on RadAjax callback: You can use the ResponseScripts collection of RadAjaxManager for this purpose:

Here's my button codebehind:

 

protected void uxOkButton_Click(object sender, EventArgs e)

 

{

uxAjaxManager.ResponseScripts.Add(

"(function(){var f = function(){radalert('Please select criteria.',300,100,'Search');Sys.Application.remove_load(f);};Sys.Application.add_load(f);})()");

 

}


The radalert only pops up the second time I click on the OK button...

I know in the KB article the last post suggests using the RegisterStartupScript method of the ScriptManager to resolve the issue of the radalert not firing the first time, but I can not do this as I have a RadScriptManager on my page and you can not have both a RadScriptManager and a ScriptManager on the same page (http://telerikwatch.com/2008/05/optimization-tips-using.html).

1 Answer, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 24 Feb 2009, 08:23 AM
Hi Michael,

In your case when you use the RadAjaxManager control the Sys.Application.load event is fired, and then the script from the codebehind is loaded by RadAjaxManager. That is why the script is executed the second time when you click on the button.

In such scenario you do not need to use the Sys.Application.load event and your code should look like this :

uxAjaxManager.ResponseScripts.Add("radalert('Please select criteria.',300,100,'Search');"); 

We will change the mentioned KB article in order to cover all of the possible scenarios.



Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
Michael
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or