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

How can i register an javascript function from the page which have radlaert.

1 Answer 90 Views
Window
This is a migrated thread and some comments may be shown as answers.
Raju Kumar
Top achievements
Rank 1
Raju Kumar asked on 22 Jul 2008, 03:40 PM
i am registering an javascript in the page like:

RadScriptManager

.RegisterStartupScript(this.Page, Page.GetType(), "PopUpAlert", "javascript:FnPopupAlert();", true);


my javascript function on aspx is like

function FnPopupAlert()

{

radalert(

"Hi",400,30);
return false;

}

When i run the page an javascript undefined error is coming. Please tell what could be the reason for this because when i remove the radalert line from the function everything works fine.
Else
How can i register an javascript function from the page which have radlaert.

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 22 Jul 2008, 03:48 PM
Hi Raju,

The controls in the RadControls for ASP.NET AJAX suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadWindowManager) in the Sys.Application.add_init() method.

Here is how the client events are fired in the page life cycle:

window.onload -> Sys.Application.init -> Sys.Application.load

You can see that the client object representation of MS AJAX controls are created just as the last code on the page in the Sys.Application.init event, which is raised after the window.onload event.

That is why when you call your code in window.onload by registering the client script, the RadWindowManager will still not be created on the page and you will get an error. To avoid this problem, you can either execute your code with a small timeout, or use the Sys.Application.add_load method.

You can find additional information about this here.




Regards,
Svetlina
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
Raju Kumar
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or