[英]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);
但是它不起作用。(無錯誤)當我刪除\\ n運算符時,它的工作警報功能。 我想在文本下方看到文件名
我怎樣才能做到這一點?
嘗試\\ r \\ n換行:
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
代替\\ n。 例:
string script = "alert('Dosya/Dosyalar Başarı İle Yüklendi "+ System.Environment.NewLine + btnUpload.FileName + " ');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.