代码之家  ›  专栏  ›  技术社区  ›  Janis Veinbergs

以编程方式在/lists文件夹中部署ASPX页

  •  0
  • Janis Veinbergs  · 技术社区  · 15 年前

    我需要将ASP.NET应用程序页从程序集部署到/列表/( http://server/Lists )文件夹。

    • 如何获取“物理”页面对象 从在程序集中生成的页面?

    Project tree http://img17.imageshack.us/img17/4242/ss20090922150130.png

    • 如何将此页面部署为模块 或者是被特长收尸官?“物理”文件夹列表不存在。

    谢谢你的帮助。

    编辑:我想通过单击此按钮来执行SharePoint Designer正在执行的操作: SharePoint Designer http://img121.imageshack.us/img121/5163/ss20090923160323.png

    1 回复  |  直到 13 年前
        1
  •  1
  •   Magnus Johansson    15 年前

    我不确定你到底在追求什么,但我猜你想创建一个页面并将其签入列表?

    此代码段为Moss中的发布页执行此操作:

    using (SPWeb web = siteCollection.RootWeb)
    {
      PublishingSite publishingSite = new PublishingSite(siteCollection);
      PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
    
      // Article Page content type
      SPContentTypeId articleContentTypeID = new SPContentTypeId("0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D");
    
      PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(articleContentTypeID);
      PageLayout articlePageLayout = layouts[0];
    
      string pageName = "LegalInformation.aspx";
    
      SPQuery query = new SPQuery();
      query.Query = string.Format("" +
      "<Where>" +
        "<Eq>" +
           "<FieldRef Name='FileLeafRef' />" +
           "<Value Type='File'>{0}</Value>" +
        "</Eq>" +
      "</Where>" +
      "", pageName);
    
      // Does the file already exists ?
      PublishingPageCollection pageColl = publishingWeb.GetPublishingPages(query);
      if (pageColl.Count > 0)
      {
        return;
      }
    
      PublishingPage newPage = publishingWeb.GetPublishingPages().Add(pageName, articlePageLayout);
    
      newPage.ListItem[FieldId.Title] = "This page title";
      newPage.ListItem[FieldId.PublishingPageContent] = "<P style='MARGIN-TOP: 20px'>Your content here</P>"";
    
      newPage.Update();
    
      // Check in file
      if (newPage.ListItem.File.CheckOutStatus != SPFile.SPCheckOutStatus.None)
      {
         newPage.ListItem.File.CheckIn(string.Empty);
      }
    
      // Publish file
      newPage.ListItem.File.Publish(string.Empty);
    }