Skip Ribbon Commands
Skip to main content

Point2Share | Daniel McPherson's SharePoint Blog

:

The zevenseas Community > Blogs > Point2Share | Daniel McPherson's SharePoint Blog > Posts > Quick Tip: Using The Web Part Gallery During Development
December 30
Quick Tip: Using The Web Part Gallery During Development

When I’m building out a web part I usually approach it as follows:

  1. Create the new class
  2. Inherit from the zevenseas Web Part base class
  3. Add code to taste
  4. Compile, deploy the DLL (usually to the Bin)
  5. Open my test site, then add it by:
    1. Site Settings
    2. Web Parts (under the Galleries heading)
    3. Click on “New”
    4. Find in the list, check, and then “Populate Gallery”
  6. Return to the home page, then add my Web Part and begin testing.

It takes all of around 5 minutes. I thought it might be useful to point out a couple of advantages to this approach, particularly around the Web Part Gallery.

  1. You jump straight into the important bits, the Web Part functionality, and this is always what motivates me to get started. I hate all the feature, GUID, gunk, although yes, there are some good tools to help here. Our Web Part base class does a lot of the heavy lifting behind the scenes for us.
  2. By deploying to the Bin you can cut down on those IISResets because when you replace the DLL the new version is instantly (almost) picked up, thereby minimising any delays (of course you have CAS concerns here, unless you set the policy to Full)
  3. By using the Web Part gallery to generate the .webpart files for you, you don’t have to write them, ensuring they are always correct. While code generation is good here, to my mind this is another level of assurance.
  4. To get the .webpart file for tuning, simply:
    1. Site Settings
    2. Web Parts (under the Galleries heading)
    3. Find your web part in the list
    4. Click on the “Edit” button
    5. Then either “Export” it or “View XML”
    6. Take this, and add it into a Web Part Feature which can be activated, and test.

Finally, if you are ever having trouble finding your web part in the Web Parts “New” list, make sure you have a SafeControls entry in your Web.Config file, without it, it wont appear.

Comments

There are no comments for this post.
 

 Statistics

 
Views: 992
Comments: 0
Tags:
Published:1235 Days Ago