ScriptManager.RegisterStartupScript(Page, Type, string,string,bool)无法换行

 

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Alert","alert(\"第一行\r\n第二行\")",true);会报脚本错误

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Alert","alert(\"第一行第二行\")",true);这样就正常.

 

解决方案:

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Alert","alert('\\n第一行\\n第二行')",true);

posted @ 2020-07-20 09:57  巴蒂青葱  阅读(159)  评论(0编辑  收藏  举报