SharePoint Designer \ Data Form Web Part apostrophe bug

25 ביולי 2008

8 תגובות

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".
  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.

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.
See how the document is opening without any problems?

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

  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:
  3. Replace it with the following peace of code:
  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.

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

8 תגובות

  1. Matt Woodward25 בנובמבר 2008 ב 10:29

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

  2. Boy10023 באוקטובר 2009 ב 3:16

    The expected proportion of outcomes. ,

  3. Vincent13 ביולי 2011 ב 18:47

    Thx for the post, helped me a lot today.

  4. icons18 בספטמבר 2012 ב 1:02

    I hope, you will find the correct decision. Do not despair.

    P.S. Please review 24×24 Free Toolbar Icons from yourmailkept

  5. icon designs18 בספטמבר 2012 ב 1:42

    It was and with me. Let's discuss this question.

    P.S. Please review Icons for iPad from ewandoocom40

  6. icon clip art18 בספטמבר 2012 ב 10:19

    I join. It was and with me. We can communicate on this theme. Here or in PM.

    P.S. Please review Medical Tab Bar Icons from Iconadiprua

  7. icons18 בספטמבר 2012 ב 11:38

    You were visited with simply magnificent idea

    P.S. Please review Database Icon Set from yourmailkept1