Exemplo n.º 1
0
        // Protected Methods (1) 

        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            string webPartId = UniqueID.Md5();

            WebPartManager currentWebPartManager = WebPartManager.GetCurrentWebPartManager(Page);

            if (currentWebPartManager != null && currentWebPartManager.DisplayMode != WebPartManager.DesignDisplayMode &&
                currentWebPartManager.DisplayMode != WebPartManager.EditDisplayMode)
            {
                AddContextualTab();

                CheckRibbonBehavior();

                ClientScriptManager clientScriptManager = Page.ClientScript;

                string script = DelayScript
                                .Replace("{webPartPageComponentId}", SPRibbon.GetWebPartPageComponentId(this))
                                .Replace("{gridId}", webPartId);

                clientScriptManager.RegisterClientScriptBlock(GetType(), "ResourceGridWebPart", script);
            }

            var control = (ResourceGridUserControl)Page.LoadControl(ASCX_PATH);

            control.WebPartId        = webPartId;
            control.AutoFocus        = WebPartManager.WebParts.Count == 1;
            control.WebPartQualifier = Qualifier;
            control.WebPartHeight    = Height;

            Controls.Add(control);
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            //buildParams();

            getGanttParams();

            var webPartPageComponentId = SPRibbon.GetWebPartPageComponentId(this);

            if (!Page.ClientScript.IsClientScriptBlockRegistered(GetType(), $"listviewwebpart{webPartPageComponentId}"))
            {
                Page.ClientScript.RegisterClientScriptBlock(
                    GetType(),
                    $"listviewwebpart{webPartPageComponentId}",
                    $"<script language=\"javascript\">var mygrid{sFullGridId};var G2antt1{ZoneIndex}{ZoneID};</script>");
            }

            if (SPContext.Current.ViewContext.View != null)
            {
                AddContextualTab();

                var clientScript = Page.ClientScript;

                clientScript.RegisterClientScriptBlock(GetType(), "ContextualWebPart", DelayScript);
            }
        }
        /// <summary>
        ///     The event handler for the System.Web.UI.Control.PreRender event that occurs immediately before the Web Part is rendered to the Web Part Page it is contained on.
        /// </summary>
        /// <param name="e">A System.EventArgs that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            AddContextualTab();

            string delayScript =
                new Dictionary <string, string>
            {
                { "webPartPageComponentId", SPRibbon.GetWebPartPageComponentId(this) },
                { "allWorkGridId", _allWorkGridId },
                { "workingOnGridId", _workingOnGridId }
            }.Aggregate(DelayScript,
                        (c, p) =>
                        c.Replace(string.Format(@"{{{0}}}", p.Key),
                                  p.Value));

            ClientScriptManager clientScriptManager = Page.ClientScript;

            clientScriptManager.RegisterClientScriptBlock(GetType(), "MyWorkWebPart", delayScript);

            base.OnPreRender(e);
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            BuildParams();

            var webPartPageComponentId = SPRibbon.GetWebPartPageComponentId(this);

            if (!Page.ClientScript.IsClientScriptBlockRegistered(GetType(), $"listviewwebpart{webPartPageComponentId}"))
            {
                Page.ClientScript.RegisterClientScriptBlock(
                    GetType(),
                    $"listviewwebpart{webPartPageComponentId}",
                    $"<script language=\"javascript\">var mygrid{FullGridId};</script>");
            }

            AddContextualTab();

            var clientScript = Page.ClientScript;

            clientScript.RegisterClientScriptBlock(GetType(), ContextualWebPart, this.DelayScript);
        }
        // Protected Methods (2) 

        /// <summary>
        ///     Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            var control = (MyWorkShell)Page.LoadControl(@"~/_CONTROLTEMPLATES/MyWork/MyWorkShell.ascx");

            int totalWebPartCount = 0;

            try
            {
                totalWebPartCount = WebPartManager.WebParts.Cast <object>().Count(webPart => !webPart.GetType().Name.Equals("ContextualHelpSlideOut"));
            }
            catch { }

            control.MyWorkParams = new MyWorkParams(_crossSiteUrls, _defaultGlobalView, DisplayTitle,
                                                    _myWorkSelectedLists, MyWorkSelectedLists, PerformanceMode,
                                                    Qualifier, _selectedFields, _selectedLists, SelectedLists,
                                                    totalWebPartCount, UseCentralizedSettings, Height,
                                                    _allWorkGridId, SPRibbon.GetWebPartPageComponentId(this),
                                                    DueDayFilter, NewItemIndicator, ShowToolbar);

            control.WorkingOnParams = new WorkingOnParams(_workingOnGridId);

            Controls.Add(control);
        }
Exemplo n.º 6
0
        protected override void OnPreRender(EventArgs e)
        {
            tb.AddTimer();
            if (bHasPeriods)
            {
                if (GridType == 0)
                {
                    AddContextualTab();

                    ClientScriptManager clientScriptManager = Page.ClientScript;
                    clientScriptManager.RegisterClientScriptBlock(GetType(), "MyTimesheet", DelayScript.Replace("{webPartPageComponentId}", SPRibbon.GetWebPartPageComponentId(this)).Replace("{TSOBJECT}", "TSObject" + sFullGridId));
                }
                CssRegistration.Register("/_layouts/epmlive/MyTimesheet.css");
                CssRegistration.Register("/_layouts/epmlive/modal/modal.css");

                ScriptLink.Register(Page, "/_layouts/epmlive/modal/modal.js", false);
                ScriptLink.Register(Page, "/_layouts/epmlive/dhtml/xgrid/dhtmlxcommon.js", false);

                EPMLiveCore.Infrastructure.EPMLiveScriptManager.RegisterScript(Page, new[]
                {
                    "/treegrid/GridE", "MyTimesheet"
                });

                //ScriptLink.Register(Page, "/_layouts/epmlive/MyTimesheet.js", false);

                ServicePointManager.ServerCertificateValidationCallback += delegate { return(true); };
            }
            base.OnPreRender(e);
            tb.StopTimer();
        }