Sunday, November 15, 2009

Experimenting with the ListFieldIterator webcontrol

In some circumstances you’ll need to display a SPListItem in its display, edit or new mode in an application page for example. In that case you can iterate through each SPField of an SPList, find the appropriate webcontrol of the field’s datatype and set the appropriate rendering mode of the webcontrol.


The quickest / easiest way to do so is by using the BaseFieldControl class.This way it doesn’t matter which field you want to render. The right control will be used.

BaseFieldControl webControl = [SPField].FieldRenderingControl;
webControl.ListId = list.ID;
webControl.ItemId = item.ID;
webControl.FieldName = [SPField].Title;
webControl.ID = GetControlID([SPField]);
webControl.ControlMode = mode;

Another way to display a SPListItem in your custom webpart or application page is by using the ListFieldIterator Webcontrol. This webcontrol renders each SPField of a SPListItem with an appropriate webcontrol. That way you get the SharePoint look & feel and the validation of your form for free.


ListFieldIterator_ListItem


If you’d like to use the ListFieldIterator and would like to give the user the ability to display, edit or create a new SPListItem without having permissions on the SPList itself … you must set the SetContextWeb property of the ListFieldIterator with your elevated SPWeb object.


ListFieldIterator_RunWithElevated

References:

Sunday, October 11, 2009

SPContext in HTTP Module

Got the 'System.InvalidOperationException' when accessing SPContext in your HTTP Module? To solve this, make sure you attach your eventhandler to the application.PreRequestHandlerExecute event instead of the application.BeginRequest event.

Thursday, July 30, 2009

How To: Extend Telerik RadEditor FlashManager with FLV Player

As you maybe know, the full-featured version of the Telerik RadEditor is able to use flash objects (.SWF files). Customers like this feature, especially in a WCM environment. However, some customers feel the need to play .FLV files into the RadEditor. Since this isn’t supported by Telerik, we have to build it ourself.


Below I’ll guide you through the steps necessary to extend the FlashManager Dialog.


TRadEditor_ToolBar


Preparation


Download (buy) the full featured-version of Telerik RadEditor (at the moment of writing the latest version is 5.5)


I noticed that the HTML field control strips out OBJECT tags. For this reason, place the Telerik RadEditor on top of a NOTE field.


Download and upload a FLV player into your SharePoint environment ( Style Library, Layouts folder, …). You can download the player here.


Extend the Telerik RadEditor


Once you are done with the preparation you can start with the real work…

Extend the configfile.xml with the following properties:


TRadEditor_ConfigXml

Download the Telerik AJAX RadControls sourcecode (I think this is only possible if you have a developer license). There you’ll find a usercontrol, named FlashManager.ascx. Copy this file into the /_layouts/[ProjectName]/RadEditor/EditorDialogs/ folder. Note: This path is equal to the ExternalDialogsPath value available in the configfile.


Open the FlashManager.ascx and search for the _getParams method. In this method you can write all your FLV magic. The code below is just a snippet.


TRadEditor_FlashJavaScript

Now we are able to select, set parameters and place a FLV player into our editor.


TRadEditor_Properties


TRadEditor_EditMode


If you find any difficulties with the implementation of a FLV player… feel free to make a comment or contact the Telerik RadEditor Team.

Saturday, July 18, 2009

Some cool stuff in InfoPath 2010!

Looks like we will use InfoPath 2010 a bit more in our daily SharePoint development... Using it, you now can customize SharePoint list forms by modifying the layout, create views, adding validation, etc...

In InfoPath 2010, we’ve made some big investments to make it much easier to build rich forms-based applications on top of the SharePoint Server 2010 platform.

For more info read - What's new in InfoPath 2010?

Wednesday, June 24, 2009

Is it time to B!ng?

Custom Document Library Item check-in throws error

I got the miserable "Value does not fall within the expected range" error after checking in an item in my newly created custom document library with a custom content type.

Since the cause of the error "Didn't fall within my knowledge range" I had to google ... and *bing!* found what I was looking for.

Lesson learned: Do not set the "required" attribute to true in your content type definition.