3

I am really wondering what the disadvantages are when using a Visual Web Part. All the books and articles on the internet only talk about the pros. But I am sure the are some disadvantages, beside the fact that you can't use them in sandboxed solutions (I am already aware of the PowerToys extensions that allows Visual Web Parts in sandboxed solutions).

4

There are plenty of disadvantages with Visual Web Parts, here's some:

  • Requires extra plumbing for Web Part Properties - from the Web Part to the User Control
  • Often gives you an overhead of objects/controls - since you rely on the designer. If you manually build your control tree you often minimize the number of used server side controls, which gives you a lesser memory footprint
  • You cannot inherit your VWP from the SharePoint Web Part implementation (you should not do that unless necessary, so it's not a major issue)
  • I find them harder to maintain (personal opinion, probably because I'm used to the traditional ones)
6
  • Thanks for this great answer. So when is it appropriate to use a VWP? And when should I write a classic Web Part?
    – Flash265
    Feb 4 '11 at 13:59
  • Another follow up question: I've seen that the VWP SPI in the Power Tools for SharePoint uses a different approach not via User Control. Would it be better to use this VWP-variant or does this have any other disadvantages?
    – Flash265
    Feb 4 '11 at 14:34
  • VWP are great for RAD scenarios, it's easier to build a UI, etc etc. The User Control based VWP is great for farm solutions, since you have an ASCX file in the SharePoint Root that can be updated w/o shutting down the app pools. Feb 5 '11 at 8:53
  • Isn't the also the disadvantage that I don't have the control over the HTML-output, since the HTML output comes from the controls I place on the designer?
    – Flash265
    Feb 7 '11 at 13:23
  • For sure, that's one reason I use traditional web parts most often. Feb 7 '11 at 15:38
2

Your web part may be unsuited to a template-based, declarative approach.

2
  • 1
    Hmm, why wouldn't SPMonitoredScope work in a VWP - that's more of a Sandbox restrictment, right? Feb 4 '11 at 13:29
  • Yup, I was thinking of a different question! Edited it.
    – SPDoctor
    Feb 5 '11 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.