我在代码隐藏类中有 RegisterStartupScript 来警告错误消息——它工作正常,除非错误有换行符或回车符(我认为)。这是片段:
注释代码工作正常!
catch (Exception ex)
{
//Page.ClientScript.ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Failure", "alert('ERROR: '), true);
Page.ClientScript.RegisterStartupScript(this.GetType(), "System Error", "alert('" + ex.Message.Replace("'", "\\'") + "');", true);
}