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.
 
A

Alek Davis

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top