Re: How to display quotes in confirmation dialog?


A

Alek Davis

Drebin,

Thanks for the advice. Actually, your example did not quite work, but it
gave me an idea, so this is what I did and it seems to be working quite
nicely:

string message = "\"Alek's \\ test.\"";
message = message.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"",
"\\\"");
button.Attributes.Add("onclick", "return confirm('" + message + "')");

Alek

Drebin said:
put a preceding \ in front of any special characters - like carraige return
\n or tab \t... so that like should read:

button.Attributes.Add("onclick", "return confirm('Alek\'s test.')");

Alek Davis said:
Hello,

I want to display a confirmation popup dialog when a user clicks a
button.
 
Ad

Advertisements

A

Alek Davis

Yes, I understand. I just wanted to show how to handle a message string,
which is a variable (not a literal).
 

Top