By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

display values in next line in alertbox

P: 94
HI,
I need to display the strings on consecutive lines. can u help. My code is like this .I know its silly to ask but please help. I used "\r" but its not working. Please can anybody tell

Expand|Select|Wrap|Line Numbers
  1. stringbuilder.errors.append("error1");
  2. stringbuilder.errors.append("error2");
  3. stringbuilder.errors.append("error3");
  4. errorlist = stringbuilder.errors.Tostring();
  5. Response.Write("<script>alert('" + errorlist + "');</script>"); 
  6.  
output should be

error1
error2
error3
Oct 15 '07 #1
Share this Question
Share on Google+
7 Replies


gits
Expert Mod 5K+
P: 5,390
hi ...

use '\n' instead ...

kind regards
Oct 15 '07 #2

P: 94
hi ...

use '\n' instead ...

kind regards
Yes I used this also. But I am getting error in js. i.e" unterminated String constant" in the status bar. I think alert box shows error with \n or \r . What to do?
Oct 15 '07 #3

gits
Expert Mod 5K+
P: 5,390
no ... the following simple example works:

Expand|Select|Wrap|Line Numbers
  1. var t1 = 'one\n';
  2. var t2 = 'two\n';
  3. var t3 = 'three\n';
  4.  
  5. alert(t1 + t2 + t3);
show what errorlist is in the following line:

Expand|Select|Wrap|Line Numbers
  1. Response.Write("<script>alert('" + errorlist + "');</script>");
kind regards
Oct 15 '07 #4

P: 94
no ... the following simple example works:

Expand|Select|Wrap|Line Numbers
  1. var t1 = 'one\n';
  2. var t2 = 'two\n';
  3. var t3 = 'three\n';
  4.  
  5. alert(t1 + t2 + t3);
show what errorlist is in the following line:

Expand|Select|Wrap|Line Numbers
  1. Response.Write("<script>alert('" + errorlist + "');</script>");
kind regards
In errorlist i will have = error1 \n error2 \n error3 \n
if i use \n in this stringbuilder.errors.append("error1\n")
Oct 15 '07 #5

gits
Expert Mod 5K+
P: 5,390
try to escape the backslash (what programming language are you using here?):

Expand|Select|Wrap|Line Numbers
  1. stringbuilder.errors.append("error1\\n");
Oct 15 '07 #6

P: 94
try to escape the backslash (what programming language are you using here?):

Expand|Select|Wrap|Line Numbers
  1. stringbuilder.errors.append("error1\\n");
yes now it worked. I use C#.net.Thank u for spending ur valuable time for me.

with regards
Sudha
Oct 15 '07 #7

gits
Expert Mod 5K+
P: 5,390
hi ...

no problem ... glad to hear you got it working ... post back to the forum anytime you have more questions ...

kind regards
Oct 15 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.