Wednesday, January 20, 2010

Newline breaks in XSLT (SharePoint DataForm Web Part)

Scenario: In a custom sharepoint .aspx page, I placed a dataform web part for display page of an item. The item has a column called "Contents". This is a field contains data as paragraphs. When I created a new item, entered data into "Contents" field with spaces between paragraphs. I want to see the data as I entered earlier in the EditForm.aspx & DisplayForm.aspx pages.

When I used , the contents field showed the data without newlines between the paragraphs.

Example:

I entered the data in NewForm.aspx as below:
"
aasdflasdf asdf asdf asdf asdf asdf.

234234aefase5asfgasdfa
asdfasdf
asdf
asdf
a

asdfasdfas"

Note: You can see spaces between the above statements. When I tried to display above content in DisplayForm.aspx, it showed without spaces & special characters as below:

"aasdflasdf asdf asdf asdf asdf asdf.234234aefase5asfgasdfaasdfasdfasdfasdfaasdfasdfas"

Solution:

Add following attributes to xsl:value-of tag:
a. select="ddwrt:AutoNewLine(string(@Contents))"
b. disable-output-escaping="yes"

Note:
1. You can find information about ddwrt:AutoNewLine at Microsoft Site.
2. disable-output-escaping="yes" attribute is meant for showing all special characters like quotes and so on.

Friday, January 15, 2010

Cannot add attachment to custom list form in SharePoint 2007

The problem is that whenever you customize a list form—for example, remove assignment and status fields from a form to submit new issues—you break the ability for the user to add attachments to the list item from that form. In most cases, we got an "Error on Page" at in the status bar with the following message shown in the Error Details:

Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.

We finally have a resolution now, although it does take code modifications to each customized list form. See the complete details here:

http://support.microsoft.com/kb/953271

**Pay careful attention to the code. For new item forms, there are SEVERAL changes required to the code and the changes must be made in multiple places.

Source: https://staceybailey.securespsites.com/blog/Lists/Posts/Post.aspx?ID=13