Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top