Blogger

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

    Recent items

Login

Today I found a problem with the LOOKUPFIELD within a page layout during the edit mode.

This is the field definition

Show/Hidden html5 code

View source
 
 
 
<SharepointWebControls:LookupField FieldName="PL_Model" ID="PL_Model" runat="server" >
 
 
 

As defined with the above code, I have a Lookup fielt to a SharePoint List and when the count is greater than 20 items I'm not able to select any item from the combo box (see the image below).

 

This email address is being protected from spambots. You need JavaScript enabled to view it. helped me to find a solution. He told me that he had the same problem a few months ago. The solution is to add the InDesign = "true" attribute to the field definition into the page layout.

Show/Hidden html5 code

View source
 
 
 
<SharepointWebControls:LookupField FieldName="PL_Model" ID="PL_Model" runat="server" InDesign="true"/>
 
 
 

Now the combo box works fine and I can select my item :)

Published in SharePoint

The function above show how to change programmatically the PageLayout (and the associated ContentType) to a PublishingPage.

Show/Hidden csharp code

View source
 
 
 
private static void ModifyPageLayout(string siteUrl, string pageName, string pageLayoutName)
{
    using (SPSite site = new SPSite(siteUrl))
    {
        using (SPWeb myWeb = site.OpenWeb())
        {
            PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(myWeb);
            
            PublishingPage page = publishingWeb.GetPublishingPage(siteUrl + "/pages/" + name);
            if (!string.IsNullOrEmpty(templateName) && page!=null)
            {
                PageLayout pl = page.PublishingWeb.GetAvailablePageLayouts().Where(p => string.Compare(p.Name, pageLayoutName, true) == 0).FirstOrDefault();
                if (pl != null)
                {
                    page.CheckOut();
                    page.Layout = pl;
                    
                    // Now set the content type
                    page.ListItem[SPBuiltInFieldId.ContentTypeId] = pl.AssociatedContentType.Id;
                    page.ListItem[SPBuiltInFieldId.ContentType] = pl.AssociatedContentType.Name;
 
                    page.Update();
                }
            }
        }
    }
}
 
 
 

Published in SharePoint