kcwallace Posted March 20, 2007 Posted March 20, 2007 I need to add an url to a table cell. I usually use the following, and it has never failed me until now. TableCell c = new TableCell(); c.Controls.Add(new LiteralControl("<a href='" + textURL + "'>" + displayText + "</a>")); Our application allows users to upload a file, and then we store the path in the database. I have found that they store several files as the following: myfolder/xxxLayout File_4.doc Unfortunately, IE translates the "nbsp;" into a space, and therefore cannot find the file. Any suggestions? Quote Go Beavs!!!
MrPaul Posted March 20, 2007 Posted March 20, 2007 HttpUtility.UrlEncode If the filename contains the literal then all you should need to do is URL-encode the filename before using it. The HttpUtility class has a method to do this: c.Controls.Add(new LiteralControl("<a href='" + HttpUtility.UrlEncode(textURL) + "'>" + displayText + "</a>")); The path myfolder/xxxLayout File_4.doc should then be output as myfolder%2fxxxLayout%26nbsp%3bFile_4.doc. Another approach would be to stop using the LiteralControl class and instead use the HtmlAnchor class. This should handle the encoding of the URL correctly, without the need for HttpUtility.UrlEncode. Either way this should give you some idea of what to do. Good luck :cool: Quote Never trouble another for what you can do for yourself.
kcwallace Posted March 21, 2007 Author Posted March 21, 2007 thank you, I will try that Quote Go Beavs!!!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.