Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 4.20 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-18-2005, 04:18 PM   PM User | #1
cooleo100d
Regular Coder

 
Join Date: Jan 2005
Location: NY, USA
Posts: 132
Thanks: 1
Thanked 1 Time in 1 Post
cooleo100d is an unknown quantity at this point
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
cooleo100d is offline   Reply With Quote
Old 07-18-2005, 04:26 PM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Two single quotes should work:
Code:
Response.Write("''this is a quote''")
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 07-18-2005, 04:32 PM   PM User | #3
cooleo100d
Regular Coder

 
Join Date: Jan 2005
Location: NY, USA
Posts: 132
Thanks: 1
Thanked 1 Time in 1 Post
cooleo100d is an unknown quantity at this point
Do you mean ''"'' will escape it? I tried it, and it didn't seem to work.
cooleo100d is offline   Reply With Quote
Old 07-18-2005, 04:52 PM   PM User | #4
cooleo100d
Regular Coder

 
Join Date: Jan 2005
Location: NY, USA
Posts: 132
Thanks: 1
Thanked 1 Time in 1 Post
cooleo100d is an unknown quantity at this point
Ok I got it. It's like:
myvar = "This is ""cool"" !!!!"
cooleo100d is offline   Reply With Quote
Old 07-18-2005, 04:57 PM   PM User | #5
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
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:
Code:
myvar = "<input type=""text"" name=""mytext"">"
Edit:
lol glad you got it working...
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 07-18-2005, 05:01 PM   PM User | #6
cooleo100d
Regular Coder

 
Join Date: Jan 2005
Location: NY, USA
Posts: 132
Thanks: 1
Thanked 1 Time in 1 Post
cooleo100d is an unknown quantity at this point
Thanks for your help.

~David
cooleo100d is offline   Reply With Quote
Old 03-19-2011, 03:15 PM   PM User | #7
boskom
New to the CF scene

 
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
boskom is an unknown quantity at this point
Quote:
Originally Posted by cooleo100d View Post
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
I know maybe this is little old topic, but for me it is pretty useful, so tnx for the tip
boskom is offline   Reply With Quote
Old 10-07-2011, 08:18 AM   PM User | #8
robertsams23
New Coder

 
Join Date: Mar 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
robertsams23 is an unknown quantity at this point
ASP.NET Single Quotes problem

You can replace single quotes with two single quotes.

http://asp.net-informations.com/dbpr...gle-quotes.htm

rbt.
robertsams23 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:42 PM.


Advertisement
Log in to turn off these ads.