Results 1 to 3 of 3

Thread: [RESOLVED] Sending double quotes to Javascript

  1. #1

    Thread Starter
    Lively Member tamjap's Avatar
    Join Date
    Jun 2007
    Posts
    99

    Resolved [RESOLVED] Sending double quotes to Javascript

    I think this will be a silly easy question.

    I have an ASP.NET page with VB.NET code behind. I am using Attributes.Add to put some javascript in the onchange event of a drop down list. I am having trouble sending a double quote. In the view source, it always shows up as ".

    vb Code:
    1. strJavascript = "getStyleClass('ExampleContent').style.backgroundImage = ""url('" & Utilities.GetAppPath & "Images\Backgrounds\Holly.jpg')"";"
    2. ddlExistingWallpaper.Attributes.Add("onchange", strJavascript)

    The code behind looks like:
    Code:
    onchange="getStyleClass('ExampleContent').style.backgroundImage = &quot;url('<RootPath>\Images\Backgrounds\Holly.jpg')&quot;;"
    How can I send a double quote as a double quote? I have also tried replacing the "" with CHR(34), but have the same results.
    • That's the way things come clear. All of a sudden. And then you realize how obvious they've been all along.

    - Madeleine L'Engle

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Sending double quotes to Javascript

    If you change this

    Code:
    onchange="getStyleClass('ExampleContent').style.backgroundImage = &quot;url('<RootPath>\Images\Backgrounds\Holly.jpg')&quot;;"
    To become

    Code:
    onchange="getStyleClass('ExampleContent').style.backgroundImage = "url('<RootPath>\Images\Backgrounds\Holly.jpg')";"
    Then that won't work at all because all that the HTML will see is

    Code:
    onchange="getStyleClass('ExampleContent').style.backgroundImage = "
    Followed by some 'unknown' text which causes an error. That is why it becomes &quot;

    Move your logic there to a function and simply call the function.

  3. #3

    Thread Starter
    Lively Member tamjap's Avatar
    Join Date
    Jun 2007
    Posts
    99

    Re: Sending double quotes to Javascript

    Oh, of course. How silly of me.

    Thank you.
    • That's the way things come clear. All of a sudden. And then you realize how obvious they've been all along.

    - Madeleine L'Engle

Posting Permissions

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



Click Here to Expand Forum to Full Width