apostrophe in href path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I'm trying to create a clickable link, but the pesky apostrophe is
preventing the link from getting displayed properly. I'm displaying the
contents of a folder (with contains the apostrophe), with the filename as a
clickable link. The files show up properly, but the link location cuts off at
the apostrophe.

Here's a code snippet (fi is an instance of FileInfo):

string fileList = "";

fileList = ("<a href='" + strFolderNameWithApos + "\\" + fi.Name + "'>" +
fi.Name + "</a>");

labelText.Text = fileList;

I've tried replacing the apostrophe with
a double apostrophe
%27
'
&apos;

but because of the href=' ....' it interprets it literally. Other than
renaming the folder without an apostrophe, is there a way around this?

Thanks in advance.
 
HttpServerUtility.UrlEncode is your answer.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top