Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharepoint: Web Part vs. ASP.NET User Control

When creating web parts for Sharepoint, is it better to create an actual web part, or is using and ASP.NET User Control (.ascx) just as good?

I already know how to create the user controls that I need, so it seems like the extra effort of creating a web part is just unnecessary leg work.

What are the advantages of using a web part over just creating and ASP.NET user control?

like image 550
Ryan Smith Avatar asked Oct 23 '08 21:10

Ryan Smith


People also ask

Which one is best user control or web parts?

If you are doing SharePoint development I would recommend always building a control as a web part, even if you are only embedding it statically in a page layout or master page, It gives you more options for re-use while still allowing you to use it as if it was just an ASP.NET control.

What is the difference between user control and custom control in WPF?

A customControl can be styled and templated and best suited for a situation when you are building a Control Library. On the contrary, a UserControl gives you an easy way to define reusable chunk of XAML which can be reused widely in your application and when you don't need to use it as a Control Library .

What is user control in ASP.NET c#?

A User Control is a reusable page or control with an extension of . ascx and created similar to an . aspx page but the difference is that a User Control does not render on its own, it requires an . aspx page to be rendered. User Controls are very useful to avoid repetition of code for similar requirements.


1 Answers

I am a big fan of user controls except for the simplest web parts. I create a webpart that instantiates and loads the user control. There are other tools out there that you can use to expose your user control, like smartpart, but I would suggest you wrap it up yourself, as it is a good learning experience. Once you have done it once, you basically have a template for any other webpart you want to create.

Good Luck!

like image 146
AdamBT Avatar answered Dec 08 '22 16:12

AdamBT