Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
JavaScript Alert box with Multiline Text
WhatsApp
Gaurav Gupta
5y
81.1
k
0
3
25
Blog
Introduction
Many times we need to show a message in the JavaScript Alert box and want to display the message in the multi-line or multiple lines.
This blog is about how to display the JavaScript Popup box with Multiple text lines through JavaScript and also using the Code-behind (C#) code.
Display the Multiline message in Alert Box using JavaScript Code.
<
html
>
<
body
>
<
script
language
=
"javascript"
>
alert('Hi, Good Morning\nWelcome To C-SharpCorner');
</
script
>
</
body
>
</
html
>
Output:
Or, you can show the text in Multiline like this.
<
html
>
<
body
>
<
script
language
=
"javascript"
>
alert( "
ID
=
101
" + '\n' +
"
NAME
=
Georgie
" + '\n' +
"
GENDER
=
Male
"
);
</
script
>
</
body
>
</
html
>
Output:
Now, If you want to show to JavaScript Alert box using C# code.
dispalyAlert(
"Hello.\\n\\This is the Example of Multiple line JavaScript Alert box in C#."
);
private
void
dispalyAlert(string message) {
string script =
"alert('"
+ message +
"');"
;
ScriptManager.RegisterStartupScript(
this
,
typeof
(Page),
"UserSecurity"
, script,
true
);
}
JavaScript Alert box with Multiline Text
People also reading
Membership not found