I would like to share some best practices on sharepoint while creating solution/implementation for sharepoint custom application
While creating webparts I prefer that first create custom control and create object for that in your webpart class ,the main advantage of this is in future , suppose if your client want to shift to .net based application because of some reasons, he can easily move in to .net application because you have developed all the components using webcontrol class so you can reuse same controls in your .net application
I have provided sample code here
Custom Controls
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RSMTechno.Controls
{
[ToolboxData("<{0}:DemoControl =server>{0}:DemoControl>")]
public class DemoControl : WebControl
{
//create your control
protected override void OnInit(EventArgs e)
{
//add to controls collection
base.OnInit(e);
}
}
WebParts class
namespace RSMTechno.WebParts
{
public class DemoControl : system.web.UI.WebControls.WebParts.WebPart
{
}
DemoControl _dc = null;
protected override void OnInit(EventArgs e)
{
_dc = new DemoControl();
this.Title = "Demo Control….";
this.Controls.Add(_dc);
base.OnInit(e);
}
}
User controls
Usercontrols makes your development faster because no need of writing code in codebehind file for creating controls in webpart , I think every web developer will have some knowledge on html stuff so they can use html for desgining their GUI using VSIDE and they can immediately see output on screen mode, the main advantage of this is it will make your development faster when you have short deadlines
I think most of the .net guys aware of usercontrols , so need of puttingmore effort on writing in codebehind in webparts this will save time also
Suppose in future if you feel that sharepoint is not right platform for the solution you are building, you can easily move into other platform no need of putting extra effort on that and you can reuse your usercontrols
But only some people are saying that they are facing some performance problems when they use usercontrols in webparts that to in extremely large sites
WSPBiuilder
I always prefer to use wspbuilder to create features through VSIDE, because this tool will help you a lot
No need of manually creating manifest.xml , no need of specifying the DDF file so please please use wspbuilder if you want to make your sharepoint development faster
Actually when you want to uninstall your feature you have to use STSADM command or you have to use solution management to uninstall your future
But this tool will help you to install/uninstall futures through wizard; this will help those who don’t have knowledge on SharePoint
Friday, November 6, 2009
Best Practices while creating webparts
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment