javascript - 脚本管理器.RegisterStartupScript

标签 javascript asp.net

我有这个代码:

ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Ouve algum problema nos itens " + text + "');", true); 

其中 text 是一个字符串,因为我试图在短信中插入一个 \n 但没有显示任何内容。

最佳答案

您的代码文本需要两个转义符。

string text = "test \\n testing";
ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Ouve algum problema nos itens " + text + "');", true); 

使用:

string text = "test \\n testing";

代替:

string text = "test \n testing";

关于javascript - 脚本管理器.RegisterStartupScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4464075/

相关文章:

javascript - 有没有办法只显示特定行的剑道网格列?

javascript - Angular : view not updating

c# - 在 xml 中创建 cdata

c# - 使用 WebApi ( $inlinecount ) 的 OData 分页

ASP.NET 应用程序错误覆盖 404?

javascript - JavaScript 中的代码组织 : MVC? 自渲染组件?

javascript - 检测WKWebview中的按钮点击

c# - 通过指定区域性名称设置日期格式yyyyMMdd

c# - 使用 Page.Response 向用户发送文件后,页面没有响应

javascript - 何时为 API 请求刷新过期的 Firebase3(Web) token