我发现了如何在catch {}中显示错误消息,它的工作原理就像是魅力。但是该应用程序是法语的,因此我需要在消息中添加撇号('),但是它无法执行此操作。我尝试了双撇号(“),撇号(\')之前的反斜杠,引号(”“”)的撇号,但它们不起作用。
这是我的错误消息的代码。
catch
{
ScriptManager.RegisterClientScriptBlock(
this,
this.GetType(),
"alertMessage",
"alert('Erreur lors de l'enregistrement de la demande.')", true);
}
提前致谢!
您应该可以为此使用转义符。由于您是从双重转义后面的代码中调用它的:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Erreur lors de l\\'enregistrement de la demande.')", true);
要在脚本中添加换行符,应在换行符后添加两次换行符:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Erreur lors de l\\'enregistrement de la demande.\\nLinebreak shizzle.')", true);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句