.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Hide or Remove Web Part Title in SharePoint programmatically

Posted By:Dhananjay Kumar       Posted Date: January 28, 2010    Points: 25    Category: SharePoint    URL: http://www.dotnetspark.com  

Hide or Remove Web Part Title in SharePoint programmatically. This article is on very simple topic. In this article; I am going to show how to hide Web Part's title in SharePoint through code.


This article is on very simple topic. In this article; I am going to show how to hide Web Part's title in SharePoint through code.


Even this requirement of hiding WebPart title sounds relatively easier task but believe me I gave my 3 hours solving this.

Step 1 Create Web Part
  1. Create new web part by clicking File->New->Project->SharePoint and then selecting Web Part Project template. I am giving name MyWebPart.

  2. Write code for web part. For Demo purpose I am just adding a label to Web Part to display message.

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization; 
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages; 
namespace MyWebPart
   public class mywebpart : System.Web.UI.WebControls.WebParts.WebPart
  public mywebpart()
  protected override void CreateChildControls()
  // TODO: add custom rendering code here.
  Label label = new Label();
  label.Text = " This is Web Part without Title";

Step 2: Hiding the Web Part title

Open MyWebPart.webpart file. Just see in solution explorer for this file. Modify this file as below. See the code highlighted in yellow. Just comment the default Title and Description properties. If you want you could not comment Description property. But to hide title; you have to comment title property. After commenting add two properties. One for ChromeState and other for ChromeType.

  Cannot import WebPart1 Web Part.


For proper output make sure about upper and lower cases. Give properties in the same case as they listed above.

Step 3: Packaging and Deploying the WebPart
  1. Right click to the Project. After this go to debug tab. There in URL give the Site URL; where you want to deploy the Web Part. For my case I am deploying it to the Web Apllication running on port 2222. So I just pasted that URL there.

  2. Build the solution.
  3. Right click on the solution and click on Package the solution.
  4. Right click then click on Deploy Solution.
  5. You should get a successful message in output window. To see output window click View -> Output from menu of Visual Studio.
Step 4: Testing the Web Part
  1. Open the site collection where you deployed the web part.
  2. Go to Site Setting then Site Collection feature. You should able to see WebPart1 is deployed as feature and it is active. 

  3. Go to Site Action then Edit Page then add a web part. Add the MyWebPart web part ;which we created in step 2.
  4. Click on Home tab. You should able to see the Web Part without the title. See below in Red rectangle.

I shown in this article how to hide title of a Web Part. Thanks for reading 


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend