我的课堂上有这个 C# 代码:
private static void error_message(Sybase.Data.AseClient.AseException salah)
{
Page executingPage = HttpContext.Current.Handler as Page;
Type cstype = HttpContext.Current.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = executingPage.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
{
String cstext = "alert('" + salah.Message + "');";
cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
}
}
产生此代码
<script type="text/javascript">
//<![CDATA[
alert('ua_services not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
');//]]>
</script>
但是警告框没有出现,并且 Chrome 记录了一个错误“Uncaught SyntaxError: Unexpected token ILLEGAL”
我的代码有什么问题?