JavaScript 警报函数中的 html 标记
Html tags in javascript alert function
这是我的aspx.cs代码:
string script = "alert('Dosya/Dosyalar Başarı İle Yüklendi'n " + btnUpload.FileName + " ');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
但它不起作用。(无错误)当我删除'运算符时,其工作警报功能。我想在文本下方查看文件名
我该怎么做?
尝试''r'换新行:
string script = "alert('Dosya/Dosyalar Başarı İle Yüklendi ''r''n " + btnUpload.FileName + " ');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
乔恩·斯基特(Jon Skeet)回到2004年的C#转义序列
C# defines the following character escape sequences:
'' - single quote, needed for character literals
'" - double quote, needed for string literals
'' - backslash
'0 - Unicode character 0
'a - Alert (character 7)
'b - Backspace (character 8)
'f - Form feed (character 12)
'n - New line (character 10)
'r - Carriage return (character 13)
't - Horizontal tab (character 9)
'v - Vertical quote (character 11)
'uxxxx - Unicode escape sequence for character with hex value xxxx
'xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of 'uxxxx)
'Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)
您可以使用System.Environment.NewLine
而不是'。例:
string script = "alert('Dosya/Dosyalar Başarı İle Yüklendi "+ System.Environment.NewLine + btnUpload.FileName + " ');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
相关文章:
- 制作一个不带HTML a标记但在动画播放完毕后指向其他页面的超链接
- HTML标记在脚本标记中工作
- 是否可以添加这行“;“照原样”;在HTML标记中
- 一个正则表达式,用于从JS中的HTML标记中删除id、样式和类属性
- 如果匹配项在特定的html标记中,则跳过regex匹配
- 使用 Pure JS 更改 HTML 标记名称
- 如何使用javascript选择字符串的部分,添加html标记或删除部分
- HTML标记,包含带引号的JavaScript代码中的引号
- 如何在JavaScript中创建打字机效果,这将考虑html标记规则
- 将c#视图模型转换为javascript模型时转义HTML标记
- Regex剥离具有特定属性的html标记
- 如何在不创建格式错误的HTML标记的情况下分解字符串
- HTML 标记未在 AngularJS ckEditor 中应用,而是在 Ediator 中显示 HTML 元素标记代码
- 如何在angularJS中运行for循环而不使用html标记
- Riot 每个构建 HTML 标记
- 用HTML标记+ 替换关闭的HTML标记
- 存储包含html标记的文本
- Regex以转义HTML标记
- 在html标记中序列化javascript代码
- JS来显示HTML标记