0

美好的一天,这是我的代码

Page.ClientScript.RegisterStartupScript(this.GetType(), "messagebox", "<script>$(document).ready( function() { csscody.alert('<br/><h1>  Exception</h1><br/>The file that you have selected has Invalid/No matching Branch Code in our Database'"+Message+"',{onComplete: function(e){if(e){process();__doPostBack('ctl00$ContentPlaceHolder1$btndelete','');}}});return false;});</script>", false);

问题是当我将变量消息放在弹出窗口中时不显示(可能是语法错误)但是当我删除它时它显示为 usall,那么我如何将 C# 中的文本/字符串添加到上面的代码中?Message 变量包含此文本

  String  Message = 123123 <br/> 22222 <br/> 1233 <br/> 33123 <br/> 
4

2 回答 2

1

尝试

Page.ClientScript.RegisterStartupScript(this.GetType(), "messagebox", "<script>$(document).ready( function() { csscody.alert('<br/><h1>  Exception</h1><br/>The file that you have selected has Invalid/No matching Branch Code in our Database\\''"+Message+"\\',{onComplete: function(e){if(e){process();__doPostBack('ctl00$ContentPlaceHolder1$btndelete','');}}});return false;});</script>", false);
于 2013-09-27T02:31:03.800 回答
1

在附加字符串之前,您要关闭单引号Message。(实际上我认为这是一个流浪的单引号。)尝试:

...anch Code in our Database" + Message + "'...
于 2013-09-27T02:31:50.770 回答