What is the best way to create custom page in SharePoint 2007?
I'm working on asp.net custom page in SharePoint 2007 environment, would like to find out w开发者_Go百科hich 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.
I guess it would the best way to build a custom page would be determined by what kind of page you are trying to build. For a custom web part page, XSLT would be your best bet. Especially if you are wanting your page to interact with any of your SharePoint list. For a regular type of web page I would use an aspx page and create it in SharePoint Designer. One of the easiest ways to get started, in my opinion, on a custom page is to start out by creating a blank web part page in SharePoint, then opening the page in designer and doing what you want with it. This way your master page will be attached to your new custom page.
Hope this is the kind of answer you are looking for.
精彩评论