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
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(this, this.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.
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
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:
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
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
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.