如何在 javaScript 中添加 C# 字符串作为文本弹出窗口

how to add a C# string in javaScript as text popup

本文关键字:文本 窗口 字符串 javaScript 添加      更新时间:2023-09-26

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

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# 中的文本/字符串添加到上面的代码中? 消息变量包含此文本

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

在追加Message字符串之前关闭单引号。(实际上我认为这是一个杂乱的单引号。尝试:

...anch Code in our Database" + Message + "'...

试试

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);