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

show alert for errors in RadGrid ItemCommand

6 Answers 502 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ankool
Top achievements
Rank 1
ankool asked on 17 Nov 2010, 12:08 PM
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

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Nov 2010, 05:52 AM
Hello Ankool,

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

Thanks,
Princy.
0
Dante696
Top achievements
Rank 1
answered on 22 Jun 2011, 06:00 PM
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?
0
Marin
Telerik team
answered on 27 Jun 2011, 02:29 PM
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.

0
Dante696
Top achievements
Rank 1
answered on 28 Jun 2011, 05:45 PM
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
0
Marin Bratanov
Telerik team
answered on 29 Jun 2011, 10:42 AM
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.

0
Dante696
Top achievements
Rank 1
answered on 30 Jun 2011, 03:07 PM
Hi Marin.

Thank you so much for your time and your help.

Kind regards,
Felipe de Jesús Meléndez
Tags
Grid
Asked by
ankool
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dante696
Top achievements
Rank 1
Marin
Telerik team
Marin Bratanov
Telerik team
Share this question
or