コード例 #1
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try
            {
                SPWeb web = properties.Feature.Parent as SPWeb;

                foreach (SPList list in web.Lists.OfType <SPList>().Where(l => !l.Hidden))
                {
                    list.NavigateForFormsPages = false;
                    list.Update();

                    using (SPLimitedWebPartManager wpm = web.GetLimitedWebPartManager(list.DefaultNewFormUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
                    {
                        foreach (WebPart wp in wpm.WebParts)
                        {
                            if (wp is ListFormWebPart)
                            {
                                ListFormWebPart lfwp = (ListFormWebPart)wp;
                                lfwp.CSRRenderMode = CSRRenderMode.ServerRender;
                                wpm.SaveChanges(lfwp);
                            }
                        }
                    }
                }
                web.Update();
            }
            catch (Exception ex)
            {
            }
        }
コード例 #2
0
        internal void AddListFormWebPart(IDictionary action, int itemID)
        {
            SPList          list;
            SPListItem      item;
            ListFormWebPart lfwp;

            try {
                list = web.Lists [new Guid(Request.QueryString ["l"])];
                PhVals ["List_Title"] = list.Title;
                if (string.IsNullOrEmpty(Title))
                {
                    Title = list.Title;
                }
                item = list.GetItemById(itemID);
                string itemTitle = ProductPage.GetListItemTitle(item, false);
                PhVals ["Context_Title"] = PhVals ["Item_Title"] = itemTitle;
                if ((!string.IsNullOrEmpty(itemTitle)) && (itemTitle != Title))
                {
                    Title = ((string.IsNullOrEmpty(Title) ? string.Empty : (Title + " - ")) + (string.IsNullOrEmpty(itemTitle) ? ("#" + item.ID) : itemTitle));
                }
                InitWebPart(lfwp = new ListFormWebPart());
                lfwp.ControlMode = SPControlMode.Display;
                lfwp.FormType    = 4;
                lfwp.ItemContext = SPContext.GetContext(Context, itemID, list.ID, web);
                lfwp.ListName    = ProductPage.GuidBracedUpper(list.ID);
                lfwp.ListItemId  = itemID;
                lfwp.Toolbar     = "None";
                MainWebPart.Controls.Add(lfwp);
                PhVals ["WebPart_Title"] = lfwp.DisplayTitle;
            } catch (Exception ex) {
                Errors.Add(ex);
            }
        }
コード例 #3
0
        protected override void CreateChildControls()
        {
            _listEditWebPart = new ListFormWebPart();
            _listEditWebPart.HideIfNoPermissions = true;
            _listEditWebPart.ListItemId          = 1;
            _listEditWebPart.ListName            = "{43137E6B-D1B3-4144-884B-D87C7080CEFC}";
            //_listEditWebPart.ItemContext = SPContext.Current;
            //_listEditWebPart.Page = this.Page;
            _listEditWebPart.ControlMode = SPControlMode.Edit;
            _listEditWebPart.FormType    = 8;
            //_listEditWebPart.TemplateName = "ListForm";
            Controls.Add(_listEditWebPart);

            //WebPartManager manager = new WebPartManager();
        }
コード例 #4
0
        public static void SetCloseAndBackButtons(ListFormWebPart listFormWebPart)
        {
            if (listFormWebPart == null)
            {
                throw new ArgumentNullException(nameof(listFormWebPart));
            }

            var closeButton = new Button
            {
                Text          = "Close",
                CssClass      = "ms-ButtonHeightWidth",
                OnClientClick = "closePage();"
            };

            var secondCloseButton = new Button
            {
                Text          = "Close",
                CssClass      = "ms-ButtonHeightWidth",
                OnClientClick = "closePage();"
            };

            listFormWebPart.Controls[0]
            .FindControl("toolBarTbltop")
            .FindControl("RightRptControls")
            .Controls.AddAt(4, closeButton);

            listFormWebPart.Controls[0]
            .FindControl("toolBarTbl")
            .FindControl("RightRptControls")
            .Controls.AddAt(2, secondCloseButton);

            var backButton = (GoBackButton)listFormWebPart.Controls[0]
                             .FindControl("toolBarTbltop")
                             .FindControl("RightRptControls")
                             .FindControl("ctl02");

            backButton.Visible = false;

            backButton = (GoBackButton)listFormWebPart.Controls[0]
                         .FindControl("toolBarTbl")
                         .FindControl("RightRptControls")
                         .FindControl("ctl01");
            backButton.Visible = false;
        }