Adding Web User Controls (.ascx) to WSPBuilder Project

I was working on a SharePoint webpart in Visual Studio 2005,  few days before, creating a WSPBuilder project. At one stage i wanted to add a web user control (.ascx file) to my project and make use of it in my webpart. So i right clicked the appropriate folder i want to place it in the 12 hive and chose add new item.

But i was not able to see a Web User Control item in the list of Add New Items. I tried a few items to add the item and then thought of an ugly idea of creating the ascx in another project and copying it into this project. Then i got this solution from an online article for adding web application items support to the wspbuilder project.

1. Right click the project and choose ‘Unload Project’ from the menu.

2. Right the project node in Solution Explorer and choose Edit ProjectName.csproj.

3. Look for the highlighted line in the .csproj file.

2 <PropertyGroup>

3 <Configuration Condition= ‘$(Configuration)’ == ” >Debug</Configuration>

4 <Platform Condition= ‘$(Platform)’ == ” >AnyCPU</Platform>

5 <ProductVersion>8.0.50727</ProductVersion>

6 <SchemaVersion>2.0</SchemaVersion>

7 <ProjectGuid>{375819D3-5E9F-41ED-B8A5-2888B82C2539}</ProjectGuid>

8 <OutputType>Library</OutputType>

9 <AppDesignerFolder>Properties</AppDesignerFolder>

10 <RootNamespace>SampleWSP</RootNamespace>

11 <AssemblyName>SampleWSP</AssemblyName>

12 <ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

13 <SignAssembly>true</SignAssembly>

14 <AssemblyOriginatorKeyFile>SampleWSP.snk</AssemblyOriginatorKeyFile>

15 <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>

16 </PropertyGroup>

4. Add {349c5851-65df-11da-9384-00065b846f21} to the ProjectTypeGUIDs node.

2 <PropertyGroup>

3 <Configuration Condition= ‘$(Configuration)’ == ” >Debug</Configuration>

4 <Platform Condition= ‘$(Platform)’ == ” >AnyCPU</Platform>

5 <ProductVersion>8.0.50727</ProductVersion>

6 <SchemaVersion>2.0</SchemaVersion>

7 <ProjectGuid>{375819D3-5E9F-41ED-B8A5-2888B82C2539}</ProjectGuid>

8 <OutputType>Library</OutputType>

9 <AppDesignerFolder>Properties</AppDesignerFolder>

10 <RootNamespace>SampleWSP</RootNamespace>

11 <AssemblyName>SampleWSP</AssemblyName>

12 <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

13 <SignAssembly>true</SignAssembly>

14 <AssemblyOriginatorKeyFile>SampleWSP.snk</AssemblyOriginatorKeyFile>

15 <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>

16 </PropertyGroup>

5. Now right click the Project and choose ‘Reload Project’ and try adding a .ascx file.

You must get it now.

Note: Cross posted – http://blog.sharepointpowerpack.com/archive/2010/11/22/adding-web-user-controls-ascx-to-wspbuilder-project.aspx

NLV

Advertisements