Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am new to SharePoint 2010 development and just created a VisualWebPart in Visual Studio 2010 but it added the webpart as "VisualWebPart1".

How do I change the default name of it and make it "HelloWorld" or any name I would like to give?

Thanks

share|improve this question
    
Thank you but tell me one thing each time when I need to create a new VisualWebPart how to provide a custom name at that time which should create the VisualWebPart node with the name I provide while creating VWP. –  Mehwish Jan 24 '12 at 8:06
    
You have to first create a Empty SharePoint Project, and the add a visual webpart. This way you can give them different names. –  tarjeieo Jan 24 '12 at 8:46
    
thanks tarjeieo –  Mehwish Jan 24 '12 at 8:52
add comment

3 Answers 3

up vote 3 down vote accepted

To rename the Title that will be visible for the end user, open Elements.xml-file in the webpart-module. Locate the <File>-element and add <Property Name="Title" Value="My Display Title" />

The Elements could look like something like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
  <Module Name="ContentQueryCustomWebPart" List="113" Url="_catalogs/wp">
    <File Path="ContentQueryCustomWebPart\ContentQueryCustomWebPart.webpart" Url="ContentQueryCustomWebPart.webpart" Type="GhostableInLibrary">
      <Property Name="Group" Value="Content Rollup" />
      <Property Name="Title" Value="My Display Name" />
    </File>
  </Module>
</Elements>

If you have to rename the webpart-element in Visual Studio, you are probably better off by deleting it and creating a new one.

share|improve this answer
add comment

If you would just delete the web part and add new one with correct name?

share|improve this answer
add comment

Open your web part folder in VS2010 and find *.webpart file. In this file you should change Title property, for example

<properties>
   <property name="Title" type="string">Navigation Web Part</property>
   <property name="Description" type="string"></property>
</properties>

This title is displayed in web part list when you tries to add web part to the page.

If you would like to change name when you tries to provision web part to the page you should use @tarjeieo solution.

If you would like to change web part name that is deployed to the page, you can go to the web part settings and change Title property.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.