0

下面是我的代码

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" ,但仍然无法插入行。

4

3 回答 3

3

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

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?')};");
于 2012-07-19T19:12:58.950 回答
0
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);
于 2012-07-19T19:16:41.347 回答
0

我不知道您正在使用的组件,但是您尝试过<br />吗?如果它接受 HTML,那可能会起作用:)

于 2012-07-19T19:12:46.667 回答