Launch RadAlert from RadWindow

4 posts, 0 answers
  1. James
    James avatar
    55 posts
    Member since:
    Oct 2011

    Posted 11 Jan 2012 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Jan 2012 Link to this post

    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.
  3. James
    James avatar
    55 posts
    Member since:
    Oct 2011

    Posted 12 Jan 2012 Link to this post

    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

  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4529 posts

    Posted 13 Jan 2012 Link to this post

    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
Back to Top