0
我有我的类此C#代码:ASP.net警告框,产生的JavaScript代码,但有错误
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>
但警告框没有按” t显示,并且Chrome记录错误“Uncaught SyntaxError:Unexpected token ILLEGAL”
我的代码出了什么问题?
谢谢!我用这个'String cstext =“alert(''+ salah.Message.Replace(”\ n“,”“)+”');“;'替换部分代码 – Iyas 2013-02-14 13:20:41