show alert for errors in RadGrid ItemCommand

7 posts, 0 answers
  1. ankool
    ankool avatar
    50 posts
    Member since:
    Apr 2007

    Posted 17 Nov 2010 Link to this post

    Hi,

    I am using radgrid for a long time now. Earlier I simply use to throw exceptions which occurred in RadGrid ItemCommand or InsertCommand or UpdateCommand and they use to appear as alerts in IE.

    I don't know whether it was IE version update or rad grid version update or did I missed some property of RadGrid because of which instead of alerts all my validations are appearing as IE errors.

    I just wish to catch exceptions inside RadGrid ItemCommand or InsertCommand or UpdateCommand and show them as alerts. Please help me out with this.

    Thanks
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Nov 2010 Link to this post

    Hello Ankool,

    Please go through the following KB article to show radalert from code.
    Calling radalert from codebehind

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dante696
    Dante696 avatar
    4 posts
    Member since:
    Jan 2007

    Posted 22 Jun 2011 Link to this post

    I tried your solution, but in a few cases, the radalert doesn't display. I found that it's because in the exceptions messages come special characters like "\n" "\r", can you provide a solution to replace all the characters that made radalert doesn't display?
  5. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 27 Jun 2011 Link to this post

    Hi,

     Those characters are not supported by RadAlert so you have to remove them from the initial string message before passing it to the RadAlert method:

    string message = "RadAlert called from server. \n\r";
    message = message.Replace("\n", "");
    message = message.Replace("\r", "");
    RadWindowManager1.RadAlert(message, , .....);

    Kind regards,
    Marin
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Dante696
    Dante696 avatar
    4 posts
    Member since:
    Jan 2007

    Posted 28 Jun 2011 Link to this post

    Hi Marin.

    Thanks for your time and your answer.

    Could you help me greatly if you know what other characters might be returned by the error messages in SQL queries and are not supported by radalert this in order to avoid possible future issues.

    Kind regards,
    Felipe de Jesús Meléndez Valencia
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 29 Jun 2011 Link to this post

    Hello Felipe,

      The RadAlert accepts an HTML string to display. Characters such as \r and \n are used in a different context and it is the developer's responsibility to handle such cases. I cannot be sure what are all the possible characters that can be present in an error message, yet here is a sample google search on the matter: http://www.google.com/search?&q=SQL+queries+special+characters and one msdn article you may also find useful http://msdn.microsoft.com/en-us/library/aa226544(v=sql.80).aspx.

    Another possible approach is to escape the whole string, i.e.:
    protected void Page_Load(object sender, EventArgs e)
    {
        string message = @"RadAlert called from server. \n\r";
        Response.Write(message);
        RadWindowManager1.RadAlert(message, 300, 100, "title", "callbackFn");
    }
    to see the difference between the string output via Response.Write and the HTML string. You could also try an encoding method, for example HttpUtility.UrlEncode(), but if it will work for you depends on your custom scenario.

    Greetings,
    Marin
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. Dante696
    Dante696 avatar
    4 posts
    Member since:
    Jan 2007

    Posted 30 Jun 2011 Link to this post

    Hi Marin.

    Thank you so much for your time and your help.

    Kind regards,
    Felipe de Jesús Meléndez
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017