I found out how to show an error message in the catch{} and it works like charm. But the app is french and I need to add an apostrophe (') in the message and it can't do it. I tried double apostrophe (''), the inverted slash before apostrophe (\'), the apostrophe in quotes ("''") and they don't work.
Here's the code for my error message.
catch
{
ScriptManager.RegisterClientScriptBlock(
this,
this.GetType(),
"alertMessage",
"alert('Erreur lors de l'enregistrement de la demande.')", true);
}
Thanks in advance!
you should be able to use a escape for this. Since you're calling it from the code behind a double escape:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Erreur lors de l\\'enregistrement de la demande.')", true);
to add a line break in the script a line escape should be added with a double escape:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Erreur lors de l\\'enregistrement de la demande.\\nLinebreak shizzle.')", true);