zoukankan      html  css  js  c++  java
  • 深入浅出SharePoint——页面上添加WebPart(代码篇)

    场景1:添加List View Webpart

     //Add webpart in view by location
                        SPList oList = web.Lists[Constant._CUSTOMER_CONTRACT_LIST_TITLE];
                        ListViewWebPart oListViewWebPart = new ListViewWebPart();
                        oListViewWebPart.ZoneID = "Left";
                        oListViewWebPart.ListName = oList.ID.ToString("B").ToUpper();
                        oListViewWebPart.ViewGuid = oList.Views[0].ID.ToString("B").ToUpper();
                        SPWebPartCollection collWebParts = web.GetWebPartCollection("default.aspx", Storage.Shared);
                        System.Guid guid = collWebParts.Add(oListViewWebPart);
    

      

    场景2:添加自定义WebPart

    //Add webpart in view by location
                            string url = web.Url + "/Lists/SafetyLab/ByLocation.aspx";
                            SPFile file = web.GetFile(url);
                            SPLimitedWebPartManager webPartManager =
                            file.GetLimitedWebPartManager(PersonalizationScope.Shared);
                            Microsoft.SharePoint.WebPartPages.WebPart wpReport = new ALU.C0370A.VPPI.ReportWebPart();
                            webPartManager.AddWebPart(wpReport, "Main", 0);
    

      

  • 相关阅读:
    2019第二周作业
    求最大值及其下标
    查找整数
    2018秋季学习总结
    抓老鼠 亏了还是赚了
    币值转换
    打印沙漏
    从文本中找出url,并附上链接。
    手机端点击输入框页面会放大
    <dl>、<dt>和<dd>标记的用法
  • 原文地址:https://www.cnblogs.com/mingle/p/SharePoint_Webpart.html
Copyright © 2011-2022 走看看