Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line in Javascript confirmation message

I've a .Net application wherein one of my pages, during initial page load, I'm setting the text of an asp label control. In my aspx page, I've a Javascript function to read the label text and show a confirmation pop-up message. The problem is, "\n" with in the label text is not introducing a line break in the JS confirmation message.

My Code Behind

lblMsg.Text = "string1" + "\n" + "string2"

Aspx Page

function PendingDeleteValidate() {
    var x = document.getElementById("<%=lblMsg.ClientID%>");

    if (confirm(x.innerHTML))
        return true;
    else
        return false;
}

The JS confirmation dialog message shows:

string1\nstring2

I need to show a line break between the two strings.

like image 401
Test_User Avatar asked Jul 18 '26 16:07

Test_User


1 Answers

Try "\r\n \r\n" after title text.

function myFunction() {
    confirm("Tittle of DialogBox \r\n \r\nMessage of dialogbox. bla..bla.. bla... bla... bla..");
}

Fiddle Demo

like image 69
Rikin Patel Avatar answered Jul 20 '26 06:07

Rikin Patel