How to show a RadAlert on a modal RadWindow before closing the radwindow.

7 posts, 2 answers
  1. Tripati
    Tripati avatar
    9 posts
    Member since:
    Nov 2012

    Posted 04 Jul 2013 Link to this post

    Hi,

    How to show a RadAlert on a modal RadWindow befor closing the radwindow.

    Requirement Step:
    1) Open a page (Say EmployeeList.aspx).
    2) Open a radwindow as modal window using a button. Radwindow is navigating to other page (Say EditEmployee.aspx).
    3) Modal window contails "Save" and "Cancel" button.
    4) Once user edits the data and hit Save button - we need to show a radalert saying 'Data Saved Successfully' and the modal window needs to closed automatically.

    Problem is: As I am closing the radwindow to refresh the parent page grid, radalert message is not getting displayed. Also I can't use asp.net alert coz normal alert will not allow me to change the alert (yellow) icon to information icon. Kindly help on this

    Java script code on EditEmployee.aspx to close the modal window:

    function CloseAndRebind(args) {
                    radalert('Data Saved successfully', 330, 100, 'Client RadAlert', null);
                    GetRadWindow().BrowserWindow.refreshGrid(args);
                    GetRadWindow().close();
                }
     
    function GetRadWindow() {
                    var oWindow = null;
                    if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
     
                    return oWindow;
                }
     
    function CloseWindow() {
                    GetRadWindow().close();
                }
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 05 Jul 2013 Link to this post

    Hello Tripati,

    You need to use the callback function of the RadAlert dialog to close the RadWIndow. This will make the code execute only after the alert has closed:
    function CloseAndRebind()
    {
        function callbackFn(arg)//the value indicates how the dialog was closed
        {
            GetRadWindow().BrowserWindow.refreshGrid(args);
            GetRadWindow().close();
        }
        radalert('Data Saved successfully', 330, 100, 'Client RadAlert', callbackFn);
    }

    Details on working with these dialogs are available here:
    http://www.telerik.com/help/aspnet-ajax/window-dialogs-alert.html
    http://demos.telerik.com/aspnet-ajax/window/examples/confirmserverclicks/defaultcs.aspx

    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tripati
    Tripati avatar
    9 posts
    Member since:
    Nov 2012

    Posted 05 Jul 2013 Link to this post

    Hi Marin,

    Thanks for quick response.

    But I am facing a challenge with the 'radalert' syntax.
    radalert('Data Saved successfully', 330, 100, 'Client RadAlert', callbackFn);

    The above code is giving me null reference error. (Refer attachment)

    Is there a different way to access radalert in javascript on a modal RadWindow? I am using Q3, 2011 version.

    Kindly help on this

    Thanks
    Tripati


  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2013 Link to this post

    Hi Tripati,

    Check whether you have the RadWindowManager on your aspx page because all these RadAlert, RadConfirm and RadPrompt dialogs require a RadWindowManager on the page.

    Thanks,
    Shinu.
  6. Tripati
    Tripati avatar
    9 posts
    Member since:
    Nov 2012

    Posted 05 Jul 2013 Link to this post

    Hi Shinu,

    I have RadWindowManager on my modal window.
    <telerik:RadWindowManager ID="WindowManager" runat="server">
        </telerik:RadWindowManager>

    if I use
    radalert('Data Saved successfully', 330, 100, 'Client RadAlert', null);
     on a normal page this works, but on a modal RadWindow it fails.

    Thanks
    Tripati

  7. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 05 Jul 2013 Link to this post

    Hi guys,

    The most likely reason for such an error is the timing of the script execution. It needs to be in the Sys.Application.Load event as shown in this sticky thread and this help article, because at any earlier point the RadWindowManager control is not initialized yet.


    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
  8. Tripati
    Tripati avatar
    9 posts
    Member since:
    Nov 2012

    Posted 05 Jul 2013 Link to this post

    Hi Marin,

    Many thanks for the answer. It is working now.

    Regards
    Tripati Patro
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017