I'm not sure how Visual Web Part is different from the actual Web Part in SharePoint 2010.
Thanks!
|
I'm not sure how Visual Web Part is different from the actual Web Part in SharePoint 2010. Thanks! |
|||
|
|
|
Short explanation: As far as usage is concerned, in many common cases there are almost no actual differences - anything you can do with a webpart you could do with a visual web part. For many points of view the visual web part is only a tool that enables the developer to work with a user control instead of creating all controls in codebehind. Visual web part are born (afaik) from the SmartPart webpart project first seen on SharePoint 2007. The idea behind that project was to create a web part that could display any user control, so that programmer could work on ascx file as for any other web project instead to have to resort to programmatically create the controls via the CreateChildControl method. That said, beware that the visual web part does use a control, so it may cause issues in specific situation. First thing that comes to mind is that a visual web part is not supported in a sandbox solution (but you can use a modified template - see here or search for sandboxed visual web part in the visual studio gallery). Waldek does a great job in is blog listing all the main differences: here is the link. What follows is just an extract of his notices, reposted to avoid link rooting. Also notice that as posted by almostSharepointMaster in his answer, you should also have a look at this page from Microsoft which also provides some samples.
|
|||||||||||||
|
|
visual webpart is a webpart that contains a reference to an ascx file that contains your controls. a webpart is where you create your controls and everything else within it. visual webpart is better for the designer to change the layout without going into c# code. So you would only need to change the ascx to change the look.
the main point to take note of is this:
for more detailed info with advantages and disadvantages check: http://msdn.microsoft.com/en-us/library/hh857549(v=office.14).aspx btw im creating a visual webpart at this moment and its a bit of a pain but easier for the designer to ammend. Webparts for me is better to code by that i mean takes less time. Why? becuase i still have to make the ascx and the webpart to host the ascx :( hope it helps :) |
||||
|
|