Customizing a SharePoint Survey NewForm.aspx page


I received an interesting questions from one of our customers: “How can you attach images to some questions in a SharePoint survey?” The solution is actually simple: Create your survey and let’s do the magic with SharePoint Designer 2007 (This tool is now free for download…)

In my example I’ve created a survey about a few Belgium beers. Only three beers, not the whole collection Feest

These are the major steps that you need to follow:

1. Create the survey list and the questions in SharePoint

2. Modify the NewForm page in SharePoint Designer 2007
– Open your SharePoint site in SP Designer.
– Open the page "NewForm.aspx"
in this location: "…/lists/survey/NewForm.aspx"
– After the page has been loaded, go into Design Mode (one of the three tab menus on the bottom of your screen).
– Select on the page the "ListFormWebPart". You need to hide this one via the WebPart Properties page (screenshot below).

2. Open the site in Sharepoint Designer 2007
– Create now a new ListFormWebPart via the menu Insert > SharePoint  Controls > Custom List Form.
Make sure that the cursor was positioned just below the "hidden" – ListFormWebPart.

okay, the newly added ListFormWebPart gives you the possibility to modify the layout and style of the rendering:

standard layout:

layout after some HTML modifications:

Hit the "Save" button and check it out in your browser.

You will find on the internet blog post which describes the process of creating a complete new aspx file. This method will do also the work of customizations for listpages but it didn’t work on Survey lists. When i did the test my survey list crashed… Glimlach

 

 

 

 

Advertisements
This entry was posted in Sharepoint. Bookmark the permalink.

20 Responses to Customizing a SharePoint Survey NewForm.aspx page

  1. pnosek says:

    This was for me a true live saver!Editing NewForm.aspx for SharePoint survey and saving it is causing unspecified error when opening the overview.aspx page or when posting the survey (the newformas.px itself was OK). I figured out, that I can edit the page as I want, but as soon as I return the page with changes (check in), it braks and it can not be undone.Hiding the original webpart saved my balls!Thanks!

  2. Lino says:

    Are you sure this solution work ? i edit the newform.aspx but when load the page on browser , the new custom list form generate an error, thanks for your help.

  3. Ryan says:

    Thank you. This works for me on MOSS 2007.

  4. Debi says:

    Worked Great! thanks so much

  5. Kate says:

    Awesome – did the job. Thanks!

  6. Nancy says:

    Just a question: if the users are only allowed to answer the survey once, how can you catch that situation with the edited newForm? Thanks!

    • Hi Nancy

      You need to mark the option “Allow multiple Responses?” in de Survey List Settings. This works.
      You don’t need to catch something within the editform because validation is performed when you click the “Ok” button.

      It would be nice from SharePoint to disable the new button or at least mention that the user already filled in the survey.

  7. Athalis says:

    Does this solution also work with Survey Branching Logic? I always get an unspecific error. I tried to remove the columns that are only visible after the first branch but still getting that error.

    • I did not made that test but I can imagine that the xslt (even if you don’t change anything in the xslt) can break you’re branching.
      Most of the time we only need to customize a generic list, task or issue form.

  8. Leslie says:

    This worked great, but when I load it in my browser it has a header on it that shows save, cancel, paste, spelling – they are grayed out so they can’t be used but is there a way to just hide that?
    Thanks!

    • Hi Leslie
      Good question!

      One of the most easy tricks is to dive into the HTML code and search for the corresponding ID or Class attribute of the surrounding control of those buttons. When you have this information it is easy to hide it with normal CSS. Digging in the html-source is plumbing but the developer tab of your IE (Press F-12) can present the html in a nice structure way…

      .NameOfTheClass{display:none};
      #NameOfTheID{display:none};

  9. France says:

    Instructions for hiding the Save Cancel toolbar are not concise enough. Are you suggesting that this is added via a CEW? No idea how to determine the name of the class or ID from all the HTML

    • Hi France

      I don’t know exactly what you mean. Through an extra CSS file, or indeed via a CEW, gives the possibility to ‘change’ styles. Keep in mind that the ‘latest loaded’ style will be used.

      If you want to find out which class or ID is used for a specific html-component => just press the F12 button in IE. An extra window will popup which gives you a nice hierarchical overview of your page in HTML combined with all loaded styles. Even script debugging is available through this developer tool in IE.

  10. Unnath Dev says:

    How can do it if user adds New question? Does it get added to the form in run-time? Please let me know.

    • Since we modify the XSL behind the form, newly created questions will appear automatically. In this example, you will need to manually add your own “beer” images 🙂 and make your XSL as much as generic…

  11. Patje Hazes says:

    Anyone know how to set a limit number of allowed selections in checkboxes choice (form Survey)?

  12. HelenG says:

    Really helpful article. Many thanks !

  13. LisaB says:

    This helped me a lot! Thank you! Although i am using SPD 2010, I was able to use these instructions and figure out what I needed to do in SPD 2010.

    For SharePoint Designer 2010, at Step 2 above – ensure you are in design mode, with cursor in same position as instructed above. Then Insert menu from the Ribbon -> Related Item View and select the survey (list item) and leave second option set to “new form”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s