Configuring and Branding a Visual Web Part Solution for SharePoint 2010 With Visual Studio 2010

Configuring and Branding a Visual Web Part Solution for SharePoint 2010 With Visual Studio 2010

Configuring and Branding a Visual Web Part Solution for SharePoint 2010 With Visual Studio 2010

Although I originally saw the new Visual Studio Tools for SharePoint 2010 back in August 2009, this past week was the first opportunity that I was able to get down to business with them, working with a web part solution (I donât get to develop as much as Iâd like to these daysâ¦). The beauty of these tools is that they not only (finally) give you a true âF5â approach to developing SharePoint applications, but they also build out and deploy web part solutions automatically for you. Indeed, every run of your application goes through the packaging and deployment process.

Before I get into this, I want to say that to a jaded old SharePoint developer, these tools are like manna from heaven. Not only is ease of use greatly improved, but so is speed of deployment and debugging.

However, unless you want your feature to be named âFeature1â and your solution to be named âMySolutionâ, and you want your assembly to be named exactly the same as your project, youâll want to brand your solution a bit. Renaming a project and/or a component Configuring and Branding a Visual Web Part Solution for SharePoint 2010 With Visual Studio 2010 | The White Pages Page 2 of 12 Page 2 of 12

file will do a certain amount of refactoring automatically for you, but it isnât complete and there are a few gotchas. I thought that Iâd outline a few of them,and walk you through a branding process. This example uses a Visual Basic project,and there will be differences with C#, but the concepts remain the same.

1. Create your Visual Web Part, and give it a name. In this case, the name will be âHello Worldâ (Original, huh?)

2. Next, change the Web part names from âVisualWebPart1â to your name, in this case âHelloWorldâ (notice the lack of spaces). When asked to perform a rename of all references, select yes. Donât get too excited, it only changes code references.

3. Then, do a search and replace (Ctl-H) on the entire solution, and replace âVisualWebPart1â with your name â in our case âHelloWorldâ. Configuring and Branding a Visual Web Part Solution for SharePoint 2010 With Visual Studio 2010 | The White Pages Page 5 of 12 Page 5 of 12

It should find and replace 5 references (for a VB.NET project at least).

4. If you want to change the name of your assembly and/or root namespace, go to project properties and do so. In our case, the Assembly name will be changed from âHello Worldâ to âSecondFoundation.HelloWorldâ, and the root namespace will be changed from âHello_Worldâ to âSecondFoundation.HelloWorldâ.

5. Next, edit the SharePointProjectItem.spdata file. This is a hidden file and youâll need to turn on the âShow All Filesâ option in the solution explorer. This file controls the auto generation of several project components.

In the SafeControl entry, youâll find that the Namespace attribute reflects the original name of the assembly. Youâll need to update it to reflect your change:

HelloWorldUserControl.ascx) and change the Inherits attribute from the Control entry (the last line) to reflect the namespace changes.

8. Optionally, edit the Elements.xml file, and change the Group property to something meaningful.

9. Open up the Features section in the Solution Explorer, and change the name from Feature1 to something meaningful. In our case, to continue on with my highly creative theme, weâll call it HelloWorld.

10. Finally, Edit your .ascx file and add some content to allow us to see the web part on the page. Iâll leave it to you to guess what content Iâm addingâ¦.. Run your project, and add your new web part to the page that pops up. All should be well.

Sekaran Mylsamy author of Configuring and Branding a Visual Web Part Solution for SharePoint 2010 With Visual Studio 2010 is from Bangalore, India. Sekaran Mylsamy says I have totally 10 + years experience in Microsoft Technologies (.NET and SharePoint).

Go4Sharepoint, is a Microsoft Featured Community.
Microsoft, Windows, Sharepoint, Sharepoint logo, Windows logo, etc are trademarks of the Microsoft Corporation.
All product names, logos, copyrights, and trademarks mentioned are acknowledged as the registered intellectual property of their respective owners. This site is not in any way affiliated with, nor has it been authorized, sponsored, or otherwise approved by, Microsoft Corporation.