Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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).

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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)
share|improve this answer
    
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. –  Wictor Wilen MCA MCM MVP 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. –  Wictor Wilen MCA MCM MVP Feb 7 '11 at 15:38
show 2 more comments

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

share|improve this answer
1  
Hmm, why wouldn't SPMonitoredScope work in a VWP - that's more of a Sandbox restrictment, right? –  Wictor Wilen MCA MCM MVP Feb 4 '11 at 13:29
    
Yup, I was thinking of a different question! Edited it. –  SPDoctor Feb 5 '11 at 11:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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