关于replace方法,急,在线等!!!
public static void MessageBox(string Message)
{
string text1 = Message.Replace( " ' ", @ "\ ' ").Replace( "\r ", @ "\r ").Replace( "\n ", @ "\n ").Replace( "\ " ", "\\\ " ");
HttpContext.Current.Response.Write( " <script language=javascript> alert(\ " " + text1 + "\ "); </script> ");
}
为什么要在前面加一个 "@ " 符号呢?
------解决方案--------------------因为在字符串中\表示的是转意符,不会直接做为字符串的一部分,要想让\字符做为字符串的内容,那么一定要在字符串前加@以避免把\当成转意符来由系统处理.