Tuesday, August 30, 2011

Removing the OOB categories from the web part tool pane

Often while developing custom web parts for SharePoint 2010 or MOSS, sometimes it is required to hide the OOB tool pane (for e.g. Appearance, Layouts or Advanced) from the end user.

Trying for hours and scratching my head, I could not find any elegant way to achieve this. Finally I decided to use a hack via reflection.

In my custom editor part class on the CreateChildControls() method, I am calling a method HideOtherToolParts. The HideOtherToolParts iterates over the control collection for this editorpart and checks if the type of the child control is Microsoft.SharePoint.WebPartPages.WebPartToolPart and accordingly hiding that child.

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            try
            {
                this.HideOtherToolParts(this.Parent.Controls);
                //other operations
            }
            catch
            {
                throw;
            }
        }

        private void HideOtherToolParts(ControlCollection controls)
        {
            try
            {
                foreach (Control toolPart in controls)
                {
                    if (toolPart.GetType().FullName == "Microsoft.SharePoint.WebPartPages.WebPartToolPart")
                    {
                        toolPart.Visible = false;
                    }
                }
            }
            catch
            {
                throw;
            }
        }

Hope this helps!

Sunday, May 22, 2011

Open a SharePoint Modal Dialog from an InfoPath Form - Live on SharePoint Developer Team Blog

Recently I did a 5 part blog post on how to open a SharePoint Modal Dialog from an InfoPath Form on SharePoint developer team blog.

Below are the links to all the 5 parts in the series-

Friday, May 6, 2011

InfoPath Form Sandbox Deployment Utility

Deployment of an InfoPath form with code behind as a Sandbox solution can only be done using the InfoPath designer. But on a client’s production environment, it would be really difficult to use this approach for deploying InfoPath forms. So in order to mitigate this issue, the InfoPath Form Sandbox Deployment Utility can be leveraged.

The InfoPath Form Sandbox Deployment Utility is a console application which can deploy any InfoPath form with/without code behind as a sandbox solution without requiring the InfoPath client itself. This utility can be used to deploy the InfoPath form locally or on a remote server provided the user running the application is the site collection administrator for the target SharePoint site.

!!! Get Started
* Download the InfoPath Form Sandbox Deployment Utility runtime.
* Download the User Guide.