Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Location
    NY, USA
    Posts
    132
    Thanks
    1
    Thanked 1 Time in 1 Post

    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

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Two single quotes should work:
    Code:
    Response.Write("''this is a quote''")

  • #3
    Regular Coder
    Join Date
    Jan 2005
    Location
    NY, USA
    Posts
    132
    Thanks
    1
    Thanked 1 Time in 1 Post
    Do you mean ''"'' will escape it? I tried it, and it didn't seem to work.

  • #4
    Regular Coder
    Join Date
    Jan 2005
    Location
    NY, USA
    Posts
    132
    Thanks
    1
    Thanked 1 Time in 1 Post
    Ok I got it. It's like:
    myvar = "This is ""cool"" !!!!"

  • #5
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    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...

  • #6
    Regular Coder
    Join Date
    Jan 2005
    Location
    NY, USA
    Posts
    132
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thanks for your help.

    ~David

  • #7
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    New Coder
    Join Date
    Mar 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP.NET Single Quotes problem

    You can replace single quotes with two single quotes.

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

    rbt.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •