Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用确认框中的\n获取新行_C#_Javascript - Fatal编程技术网

C# 无法使用确认框中的\n获取新行

C# 无法使用确认框中的\n获取新行,c#,javascript,C#,Javascript,下面是我的代码 btnDelete.Attributes.Add("onclick", "{return ConfirmAction('You are about to Delete Order . Please Note \r\n 1. Order no longer can be retrieved \r\n 2. Changes to the order are not saved. \r\n Are you sure you wish to continue to Delete?')}

下面是我的代码

btnDelete.Attributes.Add("onclick", "{return ConfirmAction('You are about to Delete Order . Please Note \r\n  1. Order no longer can be retrieved \r\n 2. Changes to the order are not saved. \r\n Are you sure you wish to continue to Delete?')};");
我希望确认框显示带有“是”和“取消”按钮的消息,如下所示:

您将要删除订单。请注意:
1.无法再检索订单
2.不保存对订单的更改
您确定要继续删除吗


我尝试了“\n”、“\n”和“\r\n”,但仍然无法插入行

我不知道您正在使用的组件,但您是否尝试过


如果它接受HTML,这可能会起作用:)

字符串中有一个字符串,因此需要转义反斜杠:

btnDelete.Attributes.Add("onclick", "{return ConfirmAction('You are about to Delete Order . Please Note \\n  1. Order no longer can be retrieved \\n 2. Changes to the order are not saved. \\n Are you sure you wish to continue to Delete?')};");

什么是“确认”?你需要像特雷弗所说的那样摆脱你的反斜杠。\r\n vs\n的顺序是特定于浏览器的,因此您可能需要确认目标浏览器使用的内容。几个答案注释Environment.Newline。您需要了解该环境。换行符是特定于服务器的,不会根据呈现javascript的浏览器进行更改。“对于非Unix平台,包含“\r\n”的字符串,或者对于Unix平台,包含“\n”的字符串,”来自。如果您能向我解释一下Environment.Newline如何查询正在使用的浏览器并更改其输出,我将收回我的评论。您是说不能用Mono运行ASP.NET*nix吗?
String buttonString = "{return ConfirmAction('You are about to Delete Order . Please Note \r\n  1. Order no longer can be retrieved \r\n 2. Changes to the order are not saved. \r\n Are you sure you wish to continue to Delete?')};"
buttonString = buttonString.Replace("\r\n", Environment.NewLine);
btnDelete.Attributes.Add("onclick", buttonString);