Helpful Information
 
 
Category: ASP.NET
ASP.NET escape quotes?

Hi,

In ASP.NET, when you have quotes within a variable, how do you escape them?

For instance, it might look like this:
myvar = "<input type="text" name="mytext">"

I know in PHP this is so easy because you can just use a \".

Does anybody have any idea how this would be done in ASP.NET?

Thanks for your help,
~David

Two single quotes should work:


Response.Write("''this is a quote''")

Do you mean ''"'' will escape it? I tried it, and it didn't seem to work.

Ok I got it. It's like:
myvar = "This is ""cool"" !!!!"

I meant to say two double quotes my bad, if you're using c# you'll be able to use the \ sequence in occasions, but you can just go:


myvar = "<input type=""text"" name=""mytext"">"



lol glad you got it working...

Thanks for your help.

~David

Hi,

In ASP.NET, when you have quotes (http://quotesaboutlifeandhappiness.blogspot.com/) within a variable, how do you escape them?

For instance, it might look like this:
myvar = "<input type="text" name="mytext">"

I know in PHP this is so easy because you can just use a \".

Does anybody have any idea how this would be done in ASP.NET?

Thanks for your help,
~David

I know maybe this is little old topic, but for me it is pretty useful, so tnx for the tip :thumbsup:

You can replace single quotes with two single quotes.

http://asp.net-informations.com/dbpro/asp-single-quotes.htm

rbt.










privacy (GDPR)