DCSIMG
SharePoint Designer \ Data Form Web Part apostrophe bug - itaysk

SharePoint Designer \ Data Form Web Part apostrophe bug

Posted Friday, July 25, 2008 12:48 PM by Itay Shakury

Problem:
You try to use a Data Form Web Part (Data View Web Part) to display a document library in an XSLT view. You find out that documents that include an apostrophe character (') in their file name, cannot be opened or viewed. (There might be other problematic characters beside apostrophe, I haven't checked that)

Steps to reproduce:

  1. Create a document library. Add some files with apostrophe in their name to the library.
     items in library
  2. Click on one of those items. The file opens as expected.
  3. Open SharePoint Designer 2007, and browse to the document library. Open the page you have just viewed (Forms\Allitems.aspx).
  4. In design mode, right click on the document library web part (List View Web Part) and click on "Convert to XSLT view".
    convertxslt
  5. Save the page, and open it in browser.
  6. Click on one of the items again. This time the file won't open, giving you 400 error.
    400error

Cause:
This bug is happening because the URL of the file is now encoded, converting apostrophe chars to this: '. This encoding format is  good for HTML and not for URL.

To prove this, try to replace the ' part of the URL with the original apostrophe char.
proof
See how the document is opening without any problems?
working

Solution:
Modify the XSLT that SharePoint Designer generates, and use the {@ServerUrl} instead of the {@FileRef} attribute.
FileRefInXSLTView

  1. Open SharePoint Designer 2007 and navigate to the page containing the Data Form Web Part. (follow the "Steps to Reproduce" above)
  2. In Code view,search for the following peace of code:
    HREF="{@FileRef}"
  3. Replace it with the following peace of code:
    HREF="{@ServerUrl}"
  4. Save the page.

* ServerUrl does not encode apostrophe at all.If you want, you can still encode apostrophe chars (in the URL format encoding) -  Use {@EncodedAbsUrl}, or manually encode the string using XSLT or Javascript.

That's it, now browse again to that page you have just modified, and see for yourself - Opening a file with apostrophe in it's name actually works.

Comments

# SharePoint Designer Tipps

Tuesday, August 12, 2008 9:59 AM by Michael Greth MVP SharePoint Blog

Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

# SPPD102 SharePointPodcast

Thursday, August 14, 2008 4:07 PM by Michael Greth MVP SharePoint Blog

Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

# SPPD102 SharePointPodcast

Thursday, August 14, 2008 4:08 PM by SharePointPodcast.de

Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

# SPPD102 SharePointPodcast

Thursday, August 14, 2008 4:38 PM by Mirrored Blogs

Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

# re: SharePoint Designer \ Data Form Web Part apostrophe bug

Tuesday, November 25, 2008 10:29 AM by Matt Woodward

Thanks for the write up Itay, this helped me out a treat :)

# re: SharePoint Designer \ Data Form Web Part apostrophe bug

Friday, October 23, 2009 3:16 AM by Boy100

The expected   proportion of outcomes. ,

# re: SharePoint Designer \ Data Form Web Part apostrophe bug

Wednesday, July 13, 2011 6:47 PM by Vincent

Thx for the post, helped me a lot today.

# SPPD102 SharePointPodcast | SharePointPodcast

Monday, September 26, 2011 6:08 PM by SPPD102 SharePointPodcast | SharePointPodcast

Pingback from  SPPD102 SharePointPodcast   | SharePointPodcast

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: