.Net & SharePoint '07

Technical blog for .Net and all SharePoint 2007 related Information

About the author

Me(Prince) and my wife are B.E in I.T & C.S.E respectively.  I a certified MCPD: Web from 2007 Dec. I am Intrestes in Web Application, MOSS, EPM, etc.
Now working with Deira International School, as IT Application & Help Manager. I have started my career as "Software Developer" @  REACH Sewn Technologies and Consulting Pvt. Ltd, Bangalore India from Oct 2004 to Feb 2006, then as "Web & Intranet Developer" @ Fosroc International Ltd, Dubai from April 2006 to Sep 2009.
You can catch me on mail@jpy-tech.com or mail@princepy.com. Or on 00971 - 50 - 4284530 

Google Translate

Tag cloud

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

RecentComments

Comment RSS

Google Your Location


Display Rich Content in an Expression Box

When you bind an Expression Box to a Rich Text field you might be surprised to find that all of the formatting and rich content are gone, and that you are left with a single-line string of plain text. Getting the rich content to display requires only a small manual modification to the view .xsl file.

In this task we will create an Expression Box bound to a Rich Text field that displays with rich content. We will also look into an issue you might experience as a result of this modification and what can be done about it. Let's start by designing a new blank form.

Create a Rich Text Box and bind an Expression Box to it:

Open the Controls task pane.

  1. Insert a Rich Text Box into the view.
  2. In the Data Source task pane, right-click field1, and then choose Expression Box.
  3. Resize the Expression Box to be the same width as the Rich Text Box above it.

Try it:

  1. Preview the form.
  2. Add some rich content to the Rich Text field, and then click outside of the field to bind the content.

The rich content is not displayed in the Expression Box. This is because InfoPath does not consider the data type of the bound field when creating an Expression Box but instead always uses the xsl:value-of element in the XSL. The xsl:value-of element converts the results of its selection to a string by calling the string() function. To allow for rich content, we must change to use the xsl:copy-of element.

Modify the view .xsl file to allow the Expression Box to display rich content:

Choose Extract Form Files from the File menu.

  1. Select a location to save your extracted form files to, and then click OK.
  2. Close InfoPath to release the lock it places on your form files.
  3. Using a text editor, open your view .xsl file.
  4. Search for the text ExpressionBox to locate the span element that represents your Expression Box control.
  5. Change the following line from: <xsl:value-of select="my:field1"/> to: <xsl:copy-of select="my:field1/node()"/>
  6. Save the view .xsl file, and then close the text editor.
  7. Reopen your form template by right-clicking the manifest.xsf file and choosing Design.

Try it:

  1. Preview the form.
  2. Add some rich content to the Rich Text field, and then click outside of the field to bind the content.

Something you might have noticed was that if you hover over the contents of the Expression Box, a blue border appears around the field. This is uncharacteristic of an expression box, and usually an undesirable effect.

There is an issue in InfoPath that causes this blue border to appear when hovering over an Expression Box modified to display rich content when a Rich Text Box bound to the same field is in the same view. To prevent this blue border from appearing on hover, you must ensure that the Expression Box does not appear in the same view as a Rich Text Box. If the two controls are in separate views, this hover effect will not occur.

thanks Greg Collins


Posted by admin on Thursday, December 11, 2008 6:10 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Comments

guido Switzerland

Wednesday, April 22, 2009 1:09 PM

Thanks for sharing, but it doesn't work with browser forms....