[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:
strJavascript = "getStyleClass('ExampleContent').style.backgroundImage = ""url('" & Utilities.GetAppPath & "Images\Backgrounds\Holly.jpg')"";"
ddlExistingWallpaper.Attributes.Add("onchange", strJavascript)
The code behind looks like:
Code:
onchange="getStyleClass('ExampleContent').style.backgroundImage = "url('<RootPath>\Images\Backgrounds\Holly.jpg')";"
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.
Re: Sending double quotes to Javascript
If you change this
Code:
onchange="getStyleClass('ExampleContent').style.backgroundImage = "url('<RootPath>\Images\Backgrounds\Holly.jpg')";"
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 "
Move your logic there to a function and simply call the function.
Re: Sending double quotes to Javascript
Oh, of course. How silly of me.
Thank you.