我有这个代码:
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/