SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a webpart for SharePoint 2007 and have seen several posts that advise to do all the creation of controls in the code-behind. I'm transitioning from Java J2EE development so I don't have the platform history of .Net/ASP/etc.

In other places it shows how you can do the same thing by embedding the control definition into the asp page with tags

My question is this:

What is the rule governing where to implement controls? Has this rule changed recently, ASP vs ASP.Net or ASP.Net MVC maybe? Is this advice limited to SharePoint development?

share|improve this question

If you're going to be doing any SharePoint web part development, this video is a much watch and it should do a pretty good job answering your question for the SharePoint world (Visual Web Part versus Server Control). The slides are pretty nice to keep around as a quick reminder too.

SharePoint Web Part Development Best Practices

share|improve this answer
This link is dead. Do you have another source for this? – Shane Wealti Mar 25 '14 at 12:38
All of the TechEd videos have been moved to Channel9: – knight0323 Feb 9 '15 at 18:03

If you are building a Web Part you basically have two options for SharePoint 2007:

  • Build a class that inherits from the WebPart class and build the interface in CreateChildControls (there are other ways also to build the UI, but best practice is to use CCC)
  • Use SmartPart for SharePoint and use a ASP.NET user control

Plain ol ASP and MVC is out of question...

share|improve this answer

Your Answer


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.