Displaying HTML in the Dataview Webpart (DVWP)
By peter.stilgoe
If you try & display rich html columns or any other columns that uses HTML in a DVWP it will display as the actual HTML as opposed to outputting it as HTML formatted text.
If you added your data using Sharepoint designer “Insert Selected Fields” you need view your DVWP code in SPD & search for:
and replace it with
Now your data in this column will display as you expected ie. formatted with the HTML code applied.
Unable to add selected web part
By peter.stilgoe
Unable to add selected web part(s)
QueryListPart: A Web Part or Web Form Control on this page cannot be displayed or imported. The type could not be found or it is not registered as safe.
- Make sure the webpart is registered as safe in the web.config
- Make sure the assembly is accessible and in the bin folder
- Make sure the assembly name in the *.webpart definition file, matches the assembly name in the safe control element in web.config
- Make sure you don’t have more than one *.webpart file for the same web part in the web part catalog. This may happen if you changed the name of the *.webpart file.
- Restart IIS to start clean. Attach the debugger to the w3wp.exe process and try to load the page with the rogue web part. This way you can determine the exact location of the assembly you are loading.
- Check if the web part class exists by opening the assembly with reflector. This might sound funny, but in a bigger team, when different versions of assemblies are flying around it is very easy to overlook something and to use the wrong version, which so happens does not contain the web part class at all.
Thanks to http://www.mikhaildikov.com/
How to display most viewed documents from a Document Library
By peter.stilgoe
Came accross an interesting solution on Linkedin to display most viewed Documents from a Document Library in a webpart. I havnt tried it myself but sounds like it would work:
1) Install LogParser on Web App Server (Sharepoint Index Server)
2) Setup a batch file with the LogParse query of your choice.
For example:
“C:\Program Files\Log Parser 2.2\logparser” -i:IISW3C -o:XML “SELECT TOP 10 REPLACE_CHR(cs-uri-stem,’+',’ ‘) AS sUrl, EXTRACT_FILENAME(cs-uri-stem) AS sName, EXTRACT_EXTENSION(cs-uri-stem) AS sExt, COUNT(*) AS [Total Hits] INTO MYFILE.XML FROM \\WFE1\C$\Windows\system32\LogFiles\W3SVC1\*.log, \\WFE2\C$\Windows\system32\LogFiles\W3SVC1\*.log WHERE TO_UPPERCASE(sUrl) Like ‘/SITES/SPECIALSITE%%’ AND TO_UPPERCASE( sExt ) IN (‘DOCX’;'PPTX’;'PNG’;'GIF’;'JPG’;'BMP’) AND TO_UPPERCASE(sUrl) Not Like ‘%%/_T/%%’ AND TO_UPPERCASE(sUrl) Not Like ‘%%/_W/%%’ GROUP BY sUrl,sName,sExt ORDER BY [Total Hits] DESC
3) This query code search only for some documents (docx, pptx, etc.) on the site ‘/sites/specialsite’ on the default web application and site collection W3SVC1. The logs are located on WFE1 and WFE2. The log parser result file is an XML file named MYFILE.XML.
4) Daily Schedule the execute of the batch and the upload of the xml file to a sharepoint document library
5) Create an XSLT file for presentation and upload to the sharepoint document library.
6) Finally show the XML with the XML WebPart with the xml and xslt files as the parameters.
How to Prevent users from changing views in Sharepoint
By peter.stilgoe
If you need to prevent users from seeing the view menu allowing them to pick which views they want to use you can remove this easily by:
Browse to the relevant list or library
Click Site Action and select Edit Page
On the Web Part Click edit –> click Modify Shared Web Part
Change Toolbar to either ‘Summary’ or ‘No toolbar’
Now your users won’t be able to view the select ‘View’ dropdown menu
Sharepoint Javascript Error: ‘style.display’ is not null or not an object
By peter.stilgoe
If you are receiving the following error when trying to access the ‘edit’ menu of a webpart on a page:
‘style.display’ is not null or not an object
It is likely that you have some random/extra code in another webpart on the page, this typically happens if you cut & paste text from another location onto the page & it also brings over some formatting chars which upsets Sharepoint. Either:
a) Remove the offending text from another webpart on the page
b) Use something other than IE like Firefox or Google Chrome, typically using another web browser you will be able to edit the troublesome webpart.
How to add extra fields to your CQWP that dont display as standard
By peter.stilgoe
1) Export your Content Query Web part to your desktop
2) Open it with Notepad and look for the following line of code:
3) Change this line to the following, and replace the portion MYINTERNALCOUMNNAME with the internal column name for your column
4) Save your file
5) Import the web part
- Edit page
- Add Web Parts
- Switch to advanced
- Switch from browse to import
- Browse to your file and upload you file
Now when you go to apply a filter, you will see your custom column.
Formatting Text / Questions in Sharepoint Surveys
By peter.stilgoe
If you have ever tried to format text and / or insert line breaks into your questions in sharepoint surveys, you’ll know its not an easy task. However by adding some simple javascript you can format the text in your questions as you want.
Basically at the bottom of your survey page add a Content Editor Webpart & insert the follow script:
You will see the script is mapping your HTML standard HTML command to keywords to trigger your formatting.
So say you wanted your question to appear in italics, you would edit your question as normal but insert the italic keyword triggers ie.
How old are you?
To appear in italics you would write the question as:
startitalic How old are you? enditalic
Now your question will appear in italics and so on……..
If you cant edit your survey page to add you CEWP see the previous post on how to edit this page.
Need to edit a sharepoint page but there is no edit option
By peter.stilgoe
You need to edit a page in Sharepoint but the ‘Edit’ option is greyed out for example on a survey page.
Simply append NewForm.aspx with ?ToolPaneView=2 so it looks like
You now have your page in edit mode so you can add webparts etc
Content Type Toolbar Web Part
By peter.stilgoe
The Content Type Toolbar is a simple add-on that will enhance the use of SharePoint Content Types in large deployments.
The use of content types in SharePoint 2007 has a number of benefits and businesses may spend a considerable amount of time planning and deploying content type to help support their business processes. Unfortunately, the default methods of using content types may not be intuitive for most users who do not have experience with SharePoint. This problem will lead to content types not being used or being neglected by the end users. This can be avoided by training your end users, but it may be sometime before all your users receive the appropriate level of training, so in the meantime the content types are still neglected.
View PDF documents in a webpart
By peter.stilgoe
You can view PDF’s on your Sharepoint pages suprisingly easily using the CEWP.
Add a CEWP & add the following code:
The only dependency is that your clients will need Adobe Reader installed locally on their PC.
The Content editor web part and Javascript
By peter.stilgoe
If you didnt know the content editor web part (CEWP) is a great way for adding code ie. JavaScript to your Sharepoint pages without having to edit / change the actual code. You need to add the CEWP to the bottom of your Sharepoint page & add the piece of script. Hey presto, desired effect without editing the actual code, a nice clean & easy way to make mods etc.
A couple of tips if you break your page with some bad code:
If you break your Web page:
When playing with the CEWP, you run the risk of adding bad code that will break your page. SharePoint will then throw out an error message, without offering any way to undo your changes.
If this happens to you, here is a useful trick: append the “?contents=1” querystring to your URL. It will give you access to the maintenance page, where you’ll be able to get rid of the faulty Web part.
For example, if you inadvertently break this page:
http://ThisServer.com/sites/ThisSite/ThisLibrary/allitems.aspx
Enter:
http://ThisServer.com/sites/ThisSite/ThisLibrary/allitems.aspx?contents=1
A trick to edit Web Part pages:
On some pages, the edit option is not available or is grayed out. This is for example the case for the edit form of a list.
The workaround here is to append the “?ToolPaneView=2” querystring to your URL, which will switch your page to edit mode. Note that it seems to be unsupported by Microsoft, though I haven’t read an official confirmation.
For example, if you want to edit:
http://ThisServer.com/sites/ThisSite/Lists/ThisList/editform.aspx
Enter:
http://ThisServer.com/sites/ThisSite/Lists/ThisList/editform.aspx?ToolPaneView=2
Thanks to http://pathtosharepoint.wordpress.com for the above 2 tips



July 1st, 2010

![Recommend [pstilgoe]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)