I'm working on asp.net custom page in SharePoint 2007 environment, would like to find out which is the best way or best practice to build a custom page (either .aspx or .ascx)
Here are the few ways I know of.
1) create an aspx page and copy to LAYOUTS folder, then load master page OnPreInit as below
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
try
{
this.MasterPageFile = SPContext.Current.Web.MasterUrl;
}
catch { }
}
Cons: custom page unable to edit (Site Actions -> Edit)
2) Create an User Control (.ascx), copy the .ascx to \12\TEMPLATE\CONTROLTEMPLATES, then register the tag in SharePoint Page by SharePoint Designer, which is detached the page, add in user control tag, then click in without reattached the page.
Cons: the SharePoint Page not able to publish if add in webparts (correct me if I'm wrong)
3) Create an User Control (.ascx) and deploy as WebPart, copy .ascx to VirtualDirectories\YourSite
Reference: http://www.codeproject.com/KB/sharepoint/WebParticles.aspx
Pros: reusable WebPart
Cons: many steps for each deployment
Please advise if there is any better alternative way in creating custom page in SharePoint 2007.
Thank you in advance.