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

RadWindow ALERT From Code Behind NOT WORKING

5 Answers 416 Views
Window
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 23 Jan 2009, 04:20 PM
I am trying to set a simple function that will display my message in a RadWindow alert box.  I assumed it was a two step process

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

Sort by
0
Svetlina Anati
Telerik team
answered on 23 Jan 2009, 04:33 PM

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,

Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shawn
Top achievements
Rank 1
answered on 23 Jan 2009, 05:18 PM
Ahhhh, that's it - thank you!

How do I put a title on the radWindow though?
0
Georgi Tunev
Telerik team
answered on 26 Jan 2009, 06:33 AM
Hello Shawn,

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.
0
Eric
Top achievements
Rank 1
answered on 08 Apr 2009, 08:33 PM
I have tried this code but I still do not get the window to pop.  The
 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 Alert works perfect and I guess it will work, but I was hoping to have the window appear diffent to attract the users attention more.  Is there some secret. I am using RadAjaxManager and RadWinindowsManager.
0
Georgi Tunev
Telerik team
answered on 09 Apr 2009, 12:32 PM
Hi Eric,

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.
Tags
Window
Asked by
Shawn
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Shawn
Top achievements
Rank 1
Georgi Tunev
Telerik team
Eric
Top achievements
Rank 1
Share this question
or