1) - Place RadAjaxManager on page
2) - Call it in your code behind like so:
Private Sub DisplayMessage(ByVal text As String) |
RadAjaxManager1.ResponseScripts.Add("radalert('" & [text] & "', 330, 210);") |
End Sub |
This does not work - I get a Javascript error from the object.
Is there a better way?
5 Answers, 1 is accepted
Hello Shawn,
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 as shown below:
protected void Button1_Click(object sender, EventArgs e) |
{ |
RadAjaxManager1.ResponseScripts.Add(@"Sys.Application.add_load(function() |
{radalert('Welcome to RadWindow for <b>ASP.NET AJAX</b>!', 330, 210);})"); |
} |
You can find additional information about this here.
Regards,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
How do I put a title on the radWindow though?
The title of the radalert dialog is the last argument in the radalert() function.
e.g.:
radalert('Welcome to RadWindow for <b>ASP.NET AJAX</b>!', 330, 210,'My Title');
Best wishes,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click |
If Not CheckForUser() Then |
RadAjaxManager1.Alert("No users are selected!") |
RadAjaxManager1.ResponseScripts.Add("Sys.Application.add_load(function() " & vbCr & vbLf & " {radalert('Welcome to RadWindow for <b>ASP.NET AJAX</b>!', 330, 210);})") |
End If |
End Sub |
The code seems fine so at this point I cannot tell what the reason for the problem might be.
I would suggest to check the following KB article that shows how to call radalert in different scenarios - I hope it will be of help.
http://www.telerik.com/support/kb/aspnet-ajax/window/calling-radalert-from-codebehind.aspx
If you still experience problems after that, please open a support ticket and send me a sample page where I could examine your exact setup. Once I have a better view over your case, I will provide you with the appropriate solution.
Best wishes,
Georgi Tunev
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.