在 SharePoint 2007 中创建自定义页面的最佳方法是什么?

发布于 2024-11-25 08:10:35 字数 936 浏览 4 评论 0原文

我正在 SharePoint 2007 环境中处理 asp.net 自定义页面,想找出构建自定义页面(.aspx 或 .ascx)的最佳方法或最佳实践,

以下是我所知道的几种方法。

1) 创建一个 aspx 页面并复制到 LAYOUTS 文件夹,然后加载母版页 OnPreInit 如下

 protected override void OnPreInit(EventArgs e)
{
  base.OnPreInit(e);
  try
  {
      this.MasterPageFile = SPContext.Current.Web.MasterUrl;
  }
  catch { }
}

缺点:自定义页面无法编辑(站点操作 -> 编辑)

2) 创建用户控件 (.ascx),将 .ascx 复制到\12\TEMPLATE\CONTROLTEMPLATES,然后通过SharePoint Designer在SharePoint Page中注册标记,分离页面,添加用户控件标记,然后单击而不重新附加 页。

缺点:如果添加 webpart,则 SharePoint 页面无法发布(如果我错了,请纠正我)

3) 创建用户控件 (.ascx) 并部署为 WebPart,将 .ascx 复制到 VirtualDirectories\YourSite

参考:http://www.codeproject.com/KB/sharepoint/WebParticles.aspx

优点:可重用 WebPart

缺点:每次部署需要执行很多步骤

请告知在 SharePoint 2007 中创建自定义页面是否有更好的替代方法。

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一曲琵琶半遮面シ 2024-12-02 08:10:35

我想构建自定义页面的最佳方法将取决于您尝试构建的页面类型。对于自定义 Web 部件页面,XSLT 将是您的最佳选择。特别是如果您希望页面与任何 SharePoint 列表进行交互。对于常规类型的网页,我将使用 aspx 页面并在 SharePoint Designer 中创建它。我认为,开始使用自定义页面的最简单方法之一是首先在 SharePoint 中创建一个空白 Web 部件页面,然后在设计器中打开该页面并使用它执行您想要的操作。这样您的母版页将附加到新的自定义页面。

希望这就是您正在寻找的答案。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文