Saturday, June 12, 2010

Inconvenient EditmodePanel Control

You can use the EditModePanel control in a publishing scenario to control the visibility of other controls in relation to the display mode. With other words – it acts like a container that shows or hides its child controls based on the mode of the page. You can use the PageDisplayMode property to indicate whether this control is visible in Edit Mode or Display Mode.

<PublishingWebControls:EditModePanel id="EditModePanel1"
runat="server" PageDisplayMode=”Display”/>

I frequently embed two EditModePanels into my pagelayout. One with its PageDisplayMode ‘Display’ and one with ‘Edit’. This way you have a styled and an non-styled presentation of your field controls. The styled presentation will be shown only in display mode. The non-styled presentation will be only used in edit mode.

While this works great in SP 2007 – I discovered that this control behaves a little different in SP 2010. I discovered that it only works as expected if you’re an authenticated user. So, what’s the difference? Well… I noticed that when you set the PageDisplayMode property to “Display” – The child controls will never be shown for anonymous users.

I was wondering why this is the case in SP 2010, while this works great in SP 2007, so I investigated the EditModePanel class in the Microsoft.SharePoint.Publishing assembly and found the evil-doer. MS added an extra check in the CalculateShouldRender method, which prevent rendering for anonymous users:

if (!ConsoleUtilities.CheckPermissions(SPBasePermissions.EditListItems))
{
this.shouldRender = false;
}

Workaround

Create your own Panel webcontrol and write the exact same logic as the EditModePanel control – without that little check. You can check the form mode like this
if (SPContext.Current.FormContext.FormMode == SPControlMode.Display)
{
//display mode
}
else
{
//edit mode
}

Attention: Don’t write your logic in the overridden Render method, use the AddParsedSubObject method instead. If you use the Render method, you will have some problems with the Ribbon.

Saturday, May 1, 2010

Cooliris 3D Wall

This is definitely the most amazing picture - video gallery I have ever seen.

02-17-09Cooliris is a browser plug-in that revolutionizes how you find, view, and share photos and videos. Whether you're browsing the Web or your desktop, Cooliris presents media on an infinite "3D wall" that lets you enjoy content without clicking page to page.


Watch the following demo to see this cooliris stuff in action. Definitely don’t forget to watch it in full screen mode. To find out more detailed information – go to Cooliris.


Btw, I already implemented the gallery in my site and it’s working great.

Saturday, April 24, 2010

The PNG Gamma Dilemma

While working on a design I came across a strange issue with my background image (.PNG format) in IE. The colors of my image were darker… which off course ruined my whole design.

IE

IE

FF
FireFox

Formulation of the problem:

The problem arises from the fact that browsers have traditionally treated the RGB values specified in CSS (and HTML), GIF and JPEG as identical (numerically and colorimetrically). With PNG, however, the stored gamma information is used to "correct" the RGB values prior to displaying the image, which means that they won't match other design elements when viewed in certain browsers.

I was able to remove the gamma information with a freeware PNG optimizer, called PNGCrush.


For more information about this issue – read:

Sunday, March 21, 2010

Changed event in browser-enabled InfoPath form

I have designed an InfoPath form and added managed code to the changed event for a field. This works in the client preview. However, after deploying as a browser-enabled form, my changed event never triggered.


The reason is quite obvious. The form requires a postback to execute our managed code in the changed event. To realize this, you need to modify the postback settings of your control.


PostBackSettings

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.