Error with setting Yes/No field to display mode in EditForm.aspx

July 10th, 2009 | Posted by Jeffrey Paarhuis in Configuring

I was so lucky = to receive this error. It may be a bug in Sharepoint (Designer) or I may be the only one that has this problem. I hope you don’t have this “bug”, for them who have the same problem, here is the solution:

I was working on another custom page of EditForm.aspx, I have a DataForm Webpart on  the page showing me the data the way I want it. On that Dataview I have a few text fields and also a Yes/No field. I wanted the user to only see this yes/no field and not edit it.

So I go to the page with Sharepoint designer and select the field and in the properties setting the attribute ControlMode from “Edit” to “Display”. This worked fine in SPD but when I did go to the EditForm in Sharepoint I was getting the following error “An unexpected error has occurred”.  There was not much else I could change or try to resolve this. There isn’t just a property or value that needs to be set to get this working.

The ONLY way to make the page display the way you want in Sharepoint is the next one:

Go to the page in sharepoint designer, the current state of the field isn’t important. Click on the Yes/No field in the design view. Click on the arrow next to the selected field and change format to Boolean. You now see a Yes or No on the page. When you are in split view you can see a <xsl: when … /xsl:otherwise>. In this code you can change the black Yes and No between the tags to a yes and no in your preferred language. In my case that would make Yes -> Ja and No -> Nee.

The code will look like this:

<xsl:when test=”@Klant_x0020_geinformeerd=’1′ or msxsl:string-compare(string(@Klant_x0020_geinformeerd),’Yes’,”,’i’)=0 or msxsl:string-compare(string(@Klant_x0020_geinformeerd),’True’,”,’i’)=0″>Ja</xsl:when>

    <xsl:when test="@YesNoField='1' or msxsl:string-compare(string(@YesNoField),'Yes','','i')=0 or msxsl:string-compare(string(@YesNoField),'True','','i')=0">Ja</xsl:when>



Save, go to Sharepoint and enjoy your working form.

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

%d bloggers like this: