0

Im using my asp.net code behind to register some startup script.

The following code gets rendered to the browser.

var rotator = new ImageRotator('rotateImg');
rotator.AddImage('DisplayThumbnailImage.aspx?FilePath=C:\Development\Projects\TouchSA\Trunk\WebSite\Gallery\photo_4.PNG&ThumbnailWidth=535&ThumbnailHeight=316');
rotator.Rotate();

This looks right...but when the AddImage method receives the parameter, all the backslashes are gone. Why?

3 Answers 3

4

Answering your question without giving any remarks to the local url. ;)

To get an "\" you have to escape it... Like this

'DisplayThumbnailImage.aspx?FilePath=C:\\Development\\Projects\\TouchSA\\Trunk\\WebSite\\Gallery\\photo_4.PNG&ThumbnailWidth=535&ThumbnailHeight=316'
Sign up to request clarification or add additional context in comments.

1 Comment

How do I double escape the URL. When rendering the javascript from c# code, Its escaped like youve shown above. So do I need to escape the result aswell?
2

Encode your URL and you'll have no problems.

Server.UrlEncode()

To decode

Server.UrlDecode()

Comments

0

I suspect you simply need to escape the backslashes. i.e. Use \\ instead of \ in your string.

var rotator = new ImageRotator('rotateImg');
rotator.AddImage('DisplayThumbnailImage.aspx?FilePath=C:\\Development\\Projects\\TouchSA\\Trunk\\WebSite\\Gallery\\photo_4.PNG&ThumbnailWidth=535&ThumbnailHeight=316');
rotator.Rotate();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.