4

I want to use the Visual Studio designer to make controls for my WebPart... I've been pointed to two approaches that seem ok. First, SmartParts... which I'll look into later. Second was to create an ASP.NET User Control, and add it explicitly when creating the webpart, similar to figure 5 in this article. This seems like an easy approach to me.

However, I've found I can't add ASP.NET User Controls to my WebPart Solution (the template doesn't appear to be an option). Alternatively, when I try to create a WebApplication, SharePoint templates are not available. So how do I add a User Control that I can modify with the Visual Designer to a SharePoint Web Part project?


Edit:

So here is a partial answer. However, when I add that GUID to the front or the back of the two pre-existing Project GUIDs already there, I get the error, "This project type is not supported by this installation." If I add it to the middle of the list, it will load... but the ASP.NET User Control template still doesn't appear as an option.

These are the GUIDs already in use by the webpart project...

{593B0543-81F6-4436-BA1E-4747859CAAE2};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

3
  • Could you please specify which Visual Studio version/edition you are using. May 6, 2010 at 7:38
  • The ProjectTypeGuids approach is correct for VS 2008. I would double check that you have the correct GUIDs. May 6, 2010 at 8:22
  • I am using VS 2008 and SharePoint 2007... the two GUIDs listed were already in the webpart project. The new one from the article matches one created in a new web application project.
    – Anonymous
    May 6, 2010 at 16:12

3 Answers 3

1

I think you need to install this

http://cksdev.codeplex.com/

in the documentation they have mentioned about Sandboxed Visual Web Part - A visual Web Part that can be deployed as part of a sandboxed solution.

HTH

Thomson

1
  • It looks like this targets SharePoint 2010, correct? Our customer will be using only 2007 in the foreseeable future.
    – Anonymous
    May 6, 2010 at 21:03
1

These are the correct Project Type GUIDs to include the C# ASP.Net project items (such as web user controls).

If you use these then you should be able to add a user control to your project.

<ProjectTypeGuids>{349C5851-65DF-11DA-9384-00065B846F21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

2
  • so those two GUIDs are for Web Applications and Windows, respectively. Mine has an additional GUID {593B0543-81F6-4436-BA1E-4747859CAAE2} for sharepoint apps... So I have all three. While it loads, I can't add items with from the web applications. Just to double check, people can do this with SharePoint 2007 and Visual Studio 2008?
    – Anonymous
    May 6, 2010 at 21:29
  • Yup. If this is VS 2010 then GUIDs may have changed for the project templates. May 8, 2010 at 9:32
0

The article you are referring to is specific to SharePoint 2010. As your question has been tagged with SharePoint 2007 I assume SP2007 is your target environment.

Bad news, User Controls are not natively supported in SP2007, but as you mention you can take the Smart Part approach. There are some drawbacks to smart parts so you may want to have a good look at the Smart Part code and just take out the bits that deals with loading a user control into a regular SP2007 Web Part.

For more info see 'Dynamically Loading a User Control'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.