My Web Part properties won’t save. Because of no server side controls on my web part?

There are tons of reasons why a web part property won’t save, but I came across a bizarre one today.

Scenario:

  • User control web, and a web part that loads the user control. 
  • The user control had NO server side controls on it.  I was just using inline c# to render my HTML for the web part.
  • When I edited the web part properties in sharepoint, the wouldn’t save.

I was banging my head against the wall all day, and found out by accident that if there are NO SERVER SIDE controls on the web part, sharepoint won’t try to save the web part properties.  You’d think that the web part properties and the controls on the web part would be completely unrelated, but not from what I saw today.

I sincerely hope that it’s just a issue with our user control loader and doesn’t happen to anybody else, ever.

Available Value Types for CAML Queries

I must be stupid, but I couldn’t google my way onto a list of available Value Types to be used in SharePoint CAML Queries.

<Value Type=’????‘>SomeValue</Value>

I’m assuming that the list of available field types is the same as for Field elements.
But experience is showing me that they don’t all work.

I’ve successfully wrote CAML against SharePoint using the following Value Types:

  • Text
  • Number
  • DateTime
  • Guid
  • MultiChoice
  • Lookup

I have not had success with:

  • Integer

If you’ve had success with other field types, let me know!

Let TMG (ISA) redirect the user from https to http

This is an issue I’ve had twice in my life so I thought I should write about it.

The Problem

This applies to Microsoft ISA Server 2006 and TMG.

On our website we have logic that detects whether a page is HTTPS worthy.  If the page is deemed worthy (like a form), then the user is redirected to the same page but on https.
E.g.  http://www.mysite.com/someform.aspx redirects to  https://www.mysite.com/someform.aspx
However, if the page is not HTTPS worthy, like a plain content page, the opposite happens.  If HTTPS redirect to HTTP.
E.g. https://www.mysite.com/somecontent.aspx redirects to http://www.mysite.com/somecontent.aspx

So, this all works great with no ISA or TMG involved.  However, ISA/TMG does not like to fallback to HTTP if it is already serving the user on HTTPS.
In fact, ISA/TMG will actually rewrite the content in the 301/302 redirect message  to be in HTTPS if the client is already viewing the website in HTTPS, even if the web server is saying “please redirect to HTTP”.

To be clear, I’ll break it down.

  1. Request comes in for https://www.mysite.com/somecontent.aspx,
  2. We have decided that it doesn’t need to be HTTPS, so we will send a redirect command (aka response.redirect, 301 or 302) to the client: go to http://www.mysite.com/somecontent.aspx
  3. ISA/TMG being the proxy, decides that all content coming back to the client should still be HTTPS and therefore rewrites the 301/302 message as https://www.mysite.com.  Doh! Stupid ISA.
  4. Client receives the redirect message back to the exact same page that they were already on.
  5. Possible infinite redirect loop.  YAY!

The Solution

In your web publishing rule in ISA/TMG create a content rewrite rule for translating http://www.mysite.com to http://www.mysite.com.
That’s not a typo. It’s the same URL twice in the URL translation.  If you add this to your rule ISA/TMG will leave your web server references alone and NOT try rewrite them.

I hope this also saves you some pain one day.

 

 

Sharepoint 2010 Dynamic Navigation limited to 50 items?

Yup, it’s true…  For performance reasons, likely valid, the Site Map provider in Sharepoint 2010 is limited to 50.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.navigation.portalsitemapprovider.dynamicchildlimit.aspx

I found a fix for this in Sharepoint 2007 that still works for 2010.  The following will allow unlimited dynamic navigation items to be shown.

1. Edit the web config for your application.

2. Find the <sitemap> section

3.  Add the text DynamicChildLimit=”0″ to each of the following keys.

<add name=”GlobalNavSiteMapProvider” description=”CMS provider for Global navigation” type=”Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” NavigationType=”Global” EncodeOutput=”true” DynamicChildLimit=”0″/>
<add name=”CombinedNavSiteMapProvider” description=”CMS provider for Combined navigation” type=”Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” NavigationType=”Combined” EncodeOutput=”true” DynamicChildLimit=”0″/>
<add name=”CurrentNavSiteMapProvider” description=”CMS provider for Current navigation” type=”Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” NavigationType=”Current” EncodeOutput=”true” DynamicChildLimit=”0″/>
<add name=”CurrentNavSiteMapProviderNoEncode” description=”CMS provider for Current navigation, no encoding of output” type=”Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” NavigationType=”Current” EncodeOutput=”false” DynamicChildLimit=”0″/>

4.  Save and you’re good to go.

Add a field editor for the TargetTo field type (SPFieldTargetTo) in Sharepoint 2010

This took me forever to google “just right”

I was looking for a Field Editor control in SharePoint 2010 that would let me edit a TargetTo Field Type right on my Publishing Page Layout.

It was not in the usual place (Microsoft.SharePoint.WebControls), it’s actually housed in the Microsoft.Office.Server.UserProfiles Assembly in Microsoft.Office.Server.UserProfiles.dll.

Here’s what you need to add to your page layout:

<%@ Register TagPrefix=”OfficeWebControls” Namespace=”Microsoft.Office.Server.WebControls.FieldTypes” Assembly=”Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

and

<OfficeWebControls:SPFieldTargetToControl ID=”AudienceEdit” runat=”server” FieldName=”Audience” ControlMode=”Edit” />

I was able to piece this together from this sharepoint 2007 blog: http://sites.google.com/site/netsourcecode/sharepointdevelopmentblog/adding-audience-targeting-to-your-publishing-page and MSDN: http://msdn.microsoft.com/en-us/library/microsoft.office.server.webcontrols.fieldtypes.spfieldtargettocontrol.aspx