private void showMessage(string strMsg)
{
Page.RegisterStartupScript("scriptStr", "<script language='javascript'>alert('"+strMsg+"');</script>");
} 如何在strMsg中插入换行符?
以便在对话框中反应出来。
______________________________________________________________________________________________
答1:
strMsg = HttpUtility.HtmlEncode(strMsg);
______________________________________________________________________________________________
答2:
Page.RegisterStartupScript("scriptStr", "<script language='javascript'>alert('"+strMsg+"'\\n换行);</script>"); 在JS里,换行是\n,在C#里,就需要两个“\\”来表示一个“\”
“\”在C#中是转义字符
______________________________________________________________________________________________
答3:
\r\n