protected override void CreateChildControls() { buildParams(); if (SPContext.Current.ViewContext.View != null) { try { typeof(ListTitleViewSelectorMenu).GetField("m_wpSingleInit", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Page.FindControl("ctl00$PlaceHolderPageTitleInTitleArea$ctl01$ctl00").Controls[1], true); } catch { } try { typeof(ListTitleViewSelectorMenu).GetField("m_wpSingle", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(Page.FindControl("ctl00$PlaceHolderPageTitleInTitleArea$ctl01$ctl00").Controls[1], true); } catch { } } EnsureChildControls(); EPMLiveCore.Act act = new EPMLiveCore.Act(web); activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts); if (activation != 0) { return; } try { toolbar = new ViewToolBar(); toolbar.EnableViewState = false; list = SPContext.Current.List; view = SPContext.Current.ViewContext.View; SPContext context = SPContext.GetContext(this.Context, view.ID, list.ID, web); toolbar.RenderContext = context; Controls.Add(toolbar); } catch { } }
protected override void CreateChildControls() { act = new Act(SPContext.Current.Web); activation = act.CheckFeatureLicense(ActFeature.ResourcePlanner); if (activation != 0) { return; } strAction = Page.Request["action"]; curWeb = SPContext.Current.Web; { resUrl = CoreFunctions.getConfigSetting(curWeb, "EPMLiveResourceURL"); if (!string.IsNullOrWhiteSpace(resUrl)) { try { if (!resUrl.Equals(curWeb.ServerRelativeUrl, StringComparison.OrdinalIgnoreCase)) { if (resUrl.StartsWith("/")) { resWeb = curWeb.Site.OpenWeb(resUrl); } else { using (var tempSite = new SPSite(resUrl)) { resWeb = tempSite.OpenWeb(); if (!resWeb.Url.Equals(resUrl, StringComparison.OrdinalIgnoreCase)) { resWeb = null; } } } } else { resWeb = curWeb; } if (resWeb != null) { try { reslist = resWeb.Lists["Resources"]; } catch (Exception exception) { DiagTrace.WriteLine(exception); } if (reslist == null) { error = "Error: Resource list was not found."; } else { resview = reslist.DefaultView; var viewListBuilder = new StringBuilder(); foreach (SPView spView in resview.Views) { if (!spView.Hidden) { viewListBuilder.Append( spView.DefaultView ? $"<option selected value=\"{spView.Title.Replace(" ", "%20")}\">{spView.Title}</option>" : $"<option value=\"{spView.Title.Replace(" ", "%20")}\">{spView.Title}</option>"); } } viewList = viewListBuilder.ToString(); lnk = new LinkButton(); lnk.Click += lnk_Click; lnk.OnClientClick = $"Javascript:return postResources{ZoneIndex}{ZoneID}();"; lnk.Text = "<img src=\"/_layouts/images/epmlivegantt.GIF\" border=\"0\" style=\"vertical-align: middle;\"> View Resource Plan"; Controls.Add(lnk); } rcList = SPContext.Current.List; var view = SPContext.Current.ViewContext.View; toolbar = new ViewToolBar { TemplateName = "GanttViewToolBar" }; var context = SPContext.GetContext(Context, view.ID, rcList.ID, curWeb); toolbar.RenderContext = context; Controls.Add(toolbar); foreach (Control control in toolbar.Controls) { processControls(control, $"{ZoneIndex}{ZoneID}", view.ServerRelativeUrl, curWeb); } } } catch (Exception exception) { DiagTrace.WriteLine(exception); } } } }
protected override void CreateChildControls() { Act = new Act(SPContext.Current.Web); Activation = Act.CheckFeatureLicense(ActFeature.Timesheets); if (Activation != 0) { return; } var web = SPContext.Current.Web; { try { SpList = SPContext.Current.List; View = SPContext.Current.ViewContext.View; } catch (Exception exception) { Trace.WriteLine(exception); } if (View != null && SpList != null) { _viewToolbar = new ViewToolBar { TemplateName = "TSViewToolBar" }; var context = SPContext.GetContext(Context, View.ID, SpList.ID, SPContext.Current.Web); _viewToolbar.RenderContext = context; Controls.Add(_viewToolbar); foreach (Control control in _viewToolbar.Controls) { ProcessControls(control, FullGridId, View.ServerRelativeUrl, web); } _timeSheetMenu.Text = TimeSheetText; _timeSheetMenu.TemplateName = "ToolbarPMMenu"; _timeSheetMenu.ToolTip = TimeSheetText; _timeSheetMenu.MenuControl.Text = TimeSheetText; _timeSheetMenu.GetMenuItem("ApproveItems").ClientOnClickScript = $"approve{FullGridId}();"; _timeSheetMenu.GetMenuItem("RejectItems").ClientOnClickScript = $"reject{FullGridId}();"; _viewToolbar.Controls[0].Controls[1].Controls[0].Controls.AddAt(6, _timeSheetMenu); SPSecurity.RunWithElevatedPrivileges( delegate { try { using (var sqlConnection = new SqlConnection(CoreFunctions.getConnectionString(web.Site.WebApplication.Id))) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand( "SELECT * from TSPERIOD where site_id=@siteid and locked = 0 order by period_id", sqlConnection) { CommandType = CommandType.Text }) { sqlCommand.Parameters.AddWithValue("@siteid", web.Site.ID); using (var dataReader = sqlCommand.ExecuteReader()) { while (dataReader.Read()) { _dropDownList.Items.Add( new ListItem( $"{dataReader.GetDateTime(1).ToShortDateString()} - {dataReader.GetDateTime(2).ToShortDateString()}", dataReader.GetInt32(0).ToString())); Periods.Add( dataReader.GetInt32(0), $"{dataReader.GetDateTime(1).ToShortDateString()} - {dataReader.GetDateTime(2).ToShortDateString()}"); } } _dropDownList.SelectedValue = Period.ToString(); } } } catch (Exception exception) { Trace.WriteLine(exception); } }); if (Page.IsPostBack) { Page.Response.Cookies[EpmLiveTsPeriod].Value = _dropDownList.SelectedValue; Page.Response.Cookies[EpmLiveTsPeriod].Expires = DateTime.Now.AddMinutes(30); } _dropDownList.ID = "ddlPeriod"; _dropDownList.SelectedIndexChanged += ddl_SelectedIndexChanged; _dropDownList.AutoPostBack = true; _dropDownList.EnableViewState = true; _buttonNext.Click += btn_Click; _buttonNext.ImageUrl = "/_layouts/epmlive/images/right.gif"; _buttonNext.EnableViewState = true; _buttonPrev.Click += btnPrev_Click; _buttonPrev.ImageUrl = "/_layouts/epmlive/images/left.gif"; _buttonPrev.EnableViewState = true; var pnl = new Panel(); pnl.Controls.Add( new LiteralControl( "<table border=\"0\"><tr><td class=\"ms-toolbar\" valign=\"center\"><div class=\"ms-buttoninactivehover\" onmouseover=\"this.className='ms-buttonactivehover'\" onmouseout=\"this.className='ms-buttoninactivehover'\">")); pnl.Controls.Add(_buttonPrev); pnl.Controls.Add(new LiteralControl("</div></td><td valign=\"center\">")); pnl.Controls.Add(_dropDownList); pnl.Controls.Add( new LiteralControl( "</td><td valign=\"center\"><div class=\"ms-buttoninactivehover\" onmouseover=\"this.className='ms-buttonactivehover'\" onmouseout=\"this.className='ms-buttoninactivehover'\">")); pnl.Controls.Add(_buttonNext); pnl.Controls.Add(new LiteralControl("</div></td></tr></table>")); _viewToolbar.Controls[0].Controls[1].Controls[0].Controls.AddAt(7, pnl); } } }
private void CreateChildControlsInternal() { if (CheckParameters()) { if (_showTree) { _folderExplorer = new FolderExplorerControl(_listGuid, _listViewGuid) { ExpandAll = true, FollowListView = true, ID = (ID + "fe"), AutoCollapse = false, ShowCounter = _showNumberOfItems, SortHierarchy = _sortHierarchyTree, CacheService = GetCacheService() }; Controls.Add(_folderExplorer); } // we are using this control to check RootFolder and generate // upload and goback buttons // we can hide it but we need create this always _breadCrumb = new BreadCrumbControl(_listGuid, _listViewGuid) { MaxLevels = 3 }; Controls.Add(_breadCrumb); _listViewWP = new SPSListView { ListId = _listGuid, ViewId = _listViewGuid, EnableViewState = true, }; SPWeb web = SPContext.Current.Web; SPList list = web.Lists[new Guid(_listGuid)]; SPView view = list.Views[new Guid(_listViewGuid)]; SPContext context = SPContext.GetContext(Context, view.ID, list.ID, web); _toolbar = new ViewToolBar { RenderContext = context }; CustomButtons(); // Up Folder button _buttonUpFolder = new SPLinkButton { Text = SPSResources.GetResourceString("SPS_UpFolderButton"), ImageUrl = "/_layouts/images/UPFOLDER.GIF", HoverCellActiveCssClass = "ms-buttonactivehover", HoverCellInActiveCssClass = "ms-buttoninactivehover", NavigateUrl = "#", EnableViewState = false }; Controls.Add(_toolbar); Controls.Add(_listViewWP); } }