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

Radalert from radwindow

5 Answers 260 Views
Window
This is a migrated thread and some comments may be shown as answers.
iomega 55
Top achievements
Rank 1
iomega 55 asked on 06 Aug 2009, 06:33 AM
HI:

I have basepage.aspx in which I have defined scriptmanager and radwindowmanager. In this page I have a link for create a radwindow. In this new radwindow I load myfirstpage.aspx.


Is there a way for creating from codebehind a radalert window in myfirstpage.aspx, but if the scriptmanager and radwindowmanager are in the basepage.aspx?

Thanks again.

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 06 Aug 2009, 06:47 AM
Hello iomega 55,

The radalert dialog can be called only on the page where the RadWindowManager is. If you want to call it from the codebehind of a content page, you could output some JavaScript that would call top.radalert().
For example:
protected void Button1_Click(object sender, EventArgs e) 
    ScriptManager.RegisterStartupScript(thisthis.GetType(), "call_radalert""top.radalert('My Message');"true); 
 

More information on how to output JavaScript functions from codebehind is available here.

Best wishes,
Georgi Tunev
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.
0
Chandu
Top achievements
Rank 1
answered on 18 Jun 2010, 12:32 PM

I am using this code in Button Click Event :

Page.ClientScript.RegisterStartupScript(

this.GetType(), "radalert", "window.setTimeout(function(){callAlert('Error','" + objError.strMessage + "');}, 200);", true);  

 

 

 

return;


Some times it is working fine some time it is getting exception as "Microsoft JScript runtime error: Object expected"

can u provide solution ?

Thankx and regards,
Chandu.L

 

 

 

0
Svetlina Anati
Telerik team
answered on 18 Jun 2010, 03:06 PM
Hello Chandu,

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:

http://blogs.telerik.com/blogs/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx

That is why what you could do in this case is to choose one of the following options:

1) Set a bigger timeout which ensures that the manager is already created
2) Use the Sys.Application.add_load event as explained above

I hope that the provided explanation and resource are helpful, let me know how it goes.



Regards,
Svetlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chandu
Top achievements
Rank 1
answered on 21 Jun 2010, 12:56 PM

Hi Svetlina,

 I used same code what is there in the example given by you,  but that is not satisfied my requirement.still getting error as
"Microsoft JScript runtime error: Object expected"

My requirement :

 i am displaying one form in RadWidnow. in that form i have to show server side alert message ('onClick' Event).

Regards,
Chandra.L



0
Princy
Top achievements
Rank 2
answered on 21 Jun 2010, 02:55 PM
Hello Chandra,

Have you added RadWindowManager on page?

I tried following code to show RadAlert and it got worked.
CS:
 
string radalertscript = "<script language='javascript'>function f(){radalert('Welcome to RadWindow <b>Prometheus</b>!', 330, 210); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";  
Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);  

Here is the KB Article which describes more on this topic:
Calling radalert from codebehind

Could you provide the code that you used if this deos not help?

Thanks,
Princy.
Tags
Window
Asked by
iomega 55
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Chandu
Top achievements
Rank 1
Svetlina Anati
Telerik team
Princy
Top achievements
Rank 2
Share this question
or