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

Launch RadAlert from RadWindow

3 Answers 101 Views
Window
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 12 Jan 2012, 03:29 AM
Hi All,

Here's what I have:

  1. A "host" page that houses my RadWindowManager, et. al.
  2. The "host" page launches a RadWindow client side.
  3. On occasion, I need to launch a RadAlert from the RadWindow.
  4. I need to launch that RadAlert from the code behind.

I think I am pretty close, by using this article: http://www.telerik.com/help/aspnet-ajax/window-programming-opening-from-within-dialog.html

However, I am having a hell of a time calling the JavaScript from the code behind in this instance.  Here's what I have tried so far:

Dim script As String = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(MyRadAlert);</script>"
 
Me.Page.ClientScript.RegisterStartupScript(Me.[GetType](), "", script)

I've also tried about 15 variations of that.  

Thanks so much for any guidance that you can give me.

Jim

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jan 2012, 05:50 AM
Hello,

Try the following to open a RadAlert from RadWindow.
ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
  <Windows>
    <telerik:RadWindow ID="RadWindow2" runat="server">
        <ContentTemplate>
            <asp:Button ID="Button1" runat="server" Text="Alert" OnClick="Button1_Click" />
       </ContentTemplate>
    </telerik:RadWindow>
  </Windows>
</telerik:RadWindowManager>
C#:
protected void Button1_Click(object sender, EventArgs e)
   {
      RadWindowManager1.RadAlert("Are you sure?", 300, 100, "Alert", "callbackfn");
   }
Note: Define callbackfn on client side.

Thanks,
Princy.
0
James
Top achievements
Rank 1
answered on 12 Jan 2012, 06:20 PM
Hi Princy,

Thanks for the response.

I have tried to run your code but I can't run the RadAlert method of the RadWindowManager because I can't get a reference to it.  Something I may not have made clear is that I'm attempting to run this from within a record control on the page, so the code is executing from the page Controls.vb file and not the code behind. 

I'm trying to get a reference to the RadWindowManager using the following code:

 

Dim myRadWindowManager As RadWindowManager = 
DirectCast(Me.Page.FindControlRecursively("RadWindowManager1"), 
RadWindowManager)<BR>

but this fails to obtain the reference and hence prevents me from calling the RadAlert method.

Can you help point me in the right direction?

Thank you,
Jim

0
Marin Bratanov
Telerik team
answered on 13 Jan 2012, 05:15 PM
Hi Jim,

You can try casting the context to the current page so that you can find controls in it, e.g.:
Dim currentPage As Page = DirectCast(HttpContext.Current.Handler, Page)

What I would advise is that you use JavaScript, if possible, which allows you to avoid a round-trip to the server and makes the task easier. The general approach how to do this via JavaScript is shown in the following help article: http://www.telerik.com/help/aspnet-ajax/radwindow-application-alert-for-entire-page.html.


Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Window
Asked by
James
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
James
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or