By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

apostrophe in href path

P: n/a
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.
Mar 31 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Rose" <Ro**@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
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.

Mar 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.