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.
- <html>
- <body>
- <script language="javascript">
- alert('Hi, Good Morning\nWelcome To C-SharpCorner');
- </script>
- </body>
- </html>
Output:

- <html>
- <body>
- <script language="javascript">
- alert( "ID = 101" + '\n' +
- "NAME = Georgie" + '\n' +
- "GENDER = Male"
- );
- </script>
- </body>
- </html>

- 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);
- }

Join the conversation! Your thoughts help the community grow.