Wrapping long questions in SharePoint surveys
Nothing like finding a solution to a problem for the end of the year. Don't say I didn't give you anything.
I was recently asked about how to tackle long questions in surveys with SharePoint, specifically there's a problem that long questions don't wrap so you get a really ugly looking website. Go ahead, create a survey and add a really long question to it. Notice how you're stuck with horizontal bars from hell? Here's how to get rid of it.
- Create your survey as you normally would.
- Select Respond to this Survey.
- Click on the Edit with Microsoft Office FrontPage on the IE toolbar. This will launch FrontPage with the NewForm.aspx page loaded.
- Right click on the Survey form in FrontPage and select Customize SharePoint List Form from the popup menu. This will convert the form to something you can edit. NOTE: It's not pretty as all the HTML tags are now literal so be careful editing these!
- Scroll down and find a tag that starts with something like this:
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">
The rest of this tag will contain the HTML for your survey form (like I said all the HTML tags are literal so <TD> will look like <TD>) - Find the tag that looks something like this TR><TH nowrap valign=top class="ms-formlabel">
- Change the TH nowrap to TH wrap
- Save the page and return to your browser.
You'll see the change in FP and when you refresh the page in your browser. The text now wraps and all is well. Neat huh? Repeat this for each question (keep looking for the ms-formlabel class). These instructions are only for the NewForm.aspx page which is what users will see when they respond to a survey. There are still other pages which suffer from the "nowrap" tag so you'll have to edit each of those. They are:
- DispForm.aspx (used to view a single result)
- EditForm.aspx (when you edit an existing response)
- summary.aspx (when you want to see a graphical view of all responses)
AllItems.aspx and overview.aspx don't show the questions so you don't have to worry about this files.
Another way to do this is to open up the site, not the page, in FrontPage and expand the survey you want to edit using the Folder List (Alt+F1) from the View menu. From here you can just edit NewForm.aspx and the other pages directly and take out that nasty "nowrap" attribute.
Hope that helps and have a safe and happy New Year!