Link to home
Start Free TrialLog in
Avatar of jandhb
jandhb

asked on

escape apostrophe c#

I have this code...

<img src='./uploads/" + "test/'s" + ".jpg'

However in the web page it is stopping at test and not including the apostrophe and s

What am I missing?
Avatar of helpmechoose
helpmechoose
Flag of Australia image

You basically mixing up with the concept I guess.

I'm not sure what you're trying to achieve here.. folder name called uploads? and the image called test's.jpg? or s.jpg inside the subfolder of test?

Here is what I reckon you can do, create a asp.net image control,
<asp:Image ID="Image1" runat="server" />

and on code behind ... you can add the following code to Page_Load
Image1.ImageUrl = " xxxxxxx";

xxxx will be whatever path and name of the image you'd like to call to.

Hope this help


Avatar of Saber37886661
Saber37886661

if you have this: <img src='./uploads/" + "test/'s" + ".jpg' />

The the address will never work because when written as the web page will see it:
<img src='./uploads/test's.jpg' />
There is always an apostraphe in the wrong spot. to fix this change your src qotes from single to double. ie:
<img src="./uploads/" + "test/'s" + ".jpg" />
or
<img src="./uploads/test/'s.jpg" />

Hope that helps
Avatar of jandhb

ASKER

It works without the apostrophe. Like when I have tests it writes that out to the page fine.

I tried changing the single quotes to double and it produced squigly lines and it didn't like it.

Here is the full line and maybe this will help give some context and help.
Again, it works fine without the apostrophe.

And yes, uploads is a directory and test's is just the name of an image.

sb.Append("<td align='center' valign='top' style='width: 825px'><span id='spnUpload_" + ul.UploadId + "'><a href=\"./uploads/" + ul.FileName + "\" target=\"_blank\" class=\"lnkButton\"><img src='./uploads/" + "test's + ".jpg' style='border: solid 1px silver;' /></a><br>" + crlf);
ASKER CERTIFIED SOLUTION
Avatar of Saber37886661
Saber37886661

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jandhb

ASKER

<img src=\"./uploads/test's.jpg\" style=\"border: solid 1px silver;\" />

That worked. Thank you very much for your help.