RadAlert With RadAjax Issues

4 posts, 0 answers
  1. Balamurali Venkatesan
    Balamurali Venkatesan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 06 Jul 2009 Link to this post

    Hi,

    Iam using the below code to display a Rad Alert box and redirecting to a new page
    string message="Displkay Alert Message";

    radAjaxManager.ResponseScripts.Add("radalert('" + message + "', 250, 100);

     

    For redirecting we are using the javascript redirect: window.location.href ="NewPage.aspx".

    The issue here is the page gets redirected first and is not waiting for the OK button click on the Radalert.
    When we use normal alert the page is actually waiting for the user to click the OK button and then the new page is getting loaded

    Any help on this greatly appreciated
    Thanks and Regards
    V.Balamurali

  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 06 Jul 2009 Link to this post

    Hello Balamurali,

    This behavior is expected - the radalert, radprompt and radconfirm dialogs cannot block the execution thread as this is something that cannot be done with JavaScript. There is an easy workaround though - to hook to the OnClientClose event of the radalert object and to execute the code there.
    e.g.:

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <script runat="server"
     
    </script> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
        <title></title
    </head> 
    <body> 
        <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
     
        <script type="text/javascript"
     
            function alertAndNavigate() 
            { 
                var oWnd = radalert("You will be redirected to Google"); 
                oWnd.add_close(function() 
                { 
                    window.location.href = "http://www.google.com"
                }); 
            } 
         
         
         
        </script> 
     
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
        </telerik:RadWindowManager> 
        <button onclick="alertAndNavigate(); return false;"
            open RadAlert and navigate the page after that</button> 
        </form> 
    </body> 
    </html> 


    Kind regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Balamurali Venkatesan
    Balamurali Venkatesan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 06 Jul 2009 Link to this post

    Hi,

    Thanks a lot for the qucik response.Actually we need to show the Alert based on certain conditions on the server .
    The code which you suggested will display the alert message whenever they click the button. But in our case on server side button click event based on certain condiitons we need to display the alert and redirect to a new page.

    Thanks and Regards,
    V.Balamurali
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 07 Jul 2009 Link to this post

    Hello Balamurali,

    It doesn't matter if you call this code directly on the client or output it from the server - the logic still stays the same. As for outputting the JavaScript function from the server and executing it, this is a general programming task that is not directly related to the RadWindow control. There are various ways to do this which depend on the setup and the logic that you want to use. For example you could examine the suggestions provided in this blog post:
    http://blogs.telerik.com/blogs/09-05-05/executing_javascript_function_from_server-side_code.aspx


    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top