public RegionCollection(PanelBase panelbase) { _panelbase = panelbase; }
/// <summary> /// 构造函数 /// </summary> /// <param name="panelBase">面板实例</param> public RegionCollection(PanelBase panelBase) { this.panelBase = panelBase; }
/// <summary> /// 构造函数 /// </summary> /// <param name="panelBase">面板实例</param> public ToolbarCollection(PanelBase panelBase) { this.panelBase = panelBase; }
protected override void OnFirstPreRender() { base.OnFirstPreRender(); // 不渲染 RenderWrapperNode = false; // 这个是必须的,2009-08-04 // 因为每个页面都会有 PageManager 控件,每个页面要至少调用 GetPostBackEventReference 一次,以在页面产生 __doPostBack 函数。 Page.ClientScript.GetPostBackEventReference(this, ""); // Move it to ResourceManager.cs // 为页面的 Form 添加 autocomplete="off" 属性 // 参考http://www.cnblogs.com/sanshi/archive/2009/09/04/1560146.html#1635830 // Page.Form.Attributes["autocomplete"] = "off"; #region HideScrollbars if (HideScrollbars) { //if (Page.Request.UserAgent.ToLower().Contains("msie")) //{ // //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "noscroll", String.Format("window.document.body.scroll='no';"), true); // AddStartupAbsoluteScript("window.document.body.scroll='no';"); //} //else //{ // //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "noscroll", String.Format("window.document.body.style.overflow='hidden';"), true); // AddStartupAbsoluteScript("window.document.body.style.overflow='hidden';"); //} AddStartupAbsoluteScript("X.util.hideScrollbar();"); } #endregion #region PageLoading if (!PageLoadingControlExist) { string jsContent = String.Empty; if (EnablePageLoading) { jsContent += "X.util.removePageLoading(false);"; } AddStartupAbsoluteScript(jsContent); } #endregion //#region EnableAjax //if (!EnableAjax) //{ // AddStartupAbsoluteScript("X.global_disable_ajax=true;"); //} //#endregion #region AutoSizePanelID if (!String.IsNullOrEmpty(AutoSizePanelID)) { PanelBase autosizePanel = ControlUtil.FindControl(Page.Form, AutoSizePanelID) as PanelBase; if (autosizePanel != null) { #region oldcode //string resizePanelScript = String.Empty; //resizePanelScript += String.Format("{0}_resize_outerpanel=function(){{var panel=Ext.getCmp('{1}');panel.setSize(Ext.getBody().getSize());panel.doLayout();}};", ClientJavascriptID, panel.ClientID); //resizePanelScript += String.Format("{0}_resize_outerpanel();", ClientJavascriptID); //resizePanelScript += String.Format("if(Ext.isIE){{X.{0}_resize_outerpanel.defer(60);}}", ClientJavascriptID); //resizePanelScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}_resize_outerpanel();}},box);", ClientJavascriptID); //AddAbsoluteStartupScript(resizePanelScript); // X._3=new Ext.FormViewport({renderTo:"RegionPanel1_wrapper",id:"RegionPanel1",layout:"border",items:[X._1,X._2],bodyStyle:"",border:false,animCollapse:false}); #endregion // 子节点不向页面输出HTML,此PageManager向页面输出HTML autosizePanel.RenderWrapperNode = false; RenderWrapperNode = true; OB.AddProperty("layout", "fit"); OB.AddProperty("border", false); OB.AddProperty("items", String.Format("{0}", autosizePanel.XID), true); string jsContent = String.Format("var {0}=new Ext.ux.FormViewport({1});", XID, OB.ToString()); AddStartupAbsoluteScript(jsContent); } } #endregion //if (EnableBigFont) //{ // AddStartupAbsoluteScript("Ext.getBody().addClass('bigfont');"); //} #region oldcode // Move to X.util.init // Asp.Net Buttons(type="submit") // AddStartupAbsoluteScript("X.util.makeAspnetSubmitButtonAjax();"); #endregion }
protected override void OnFirstPreRender() { base.OnFirstPreRender(); if (EnableFrame) { OB.AddProperty("frame", true); } #region Items if (!RenderChildrenAsContent) { if (Items.Count > 0) { JsArrayBuilder ab = new JsArrayBuilder(); foreach (ControlBase item in Items) { if (item.Visible) { ab.AddProperty(String.Format("{0}", item.XID), true); } } OB.AddProperty("items", ab.ToString(), true); } } #endregion #region Toolbars foreach (Toolbar bar in Toolbars) { string toolbarID = String.Format("{0}", bar.XID); if (bar.Position == ToolbarPosition.Top) { OB.AddProperty("tbar", toolbarID, true); } else if (bar.Position == ToolbarPosition.Bottom) { OB.AddProperty("bbar", toolbarID, true); } } #endregion #region BodyStyle/ShowBorder string bodyStyleStr = BodyStyle; if (!bodyStyleStr.Contains("padding")) { if (!String.IsNullOrEmpty(BodyPadding)) { bodyStyleStr += String.Format("padding:{0};", BodyPadding); } } if (EnableBackgroundColor) { if (!bodyStyleStr.Contains("background-color")) { string backgroundColorStyleStr = GlobalConfig.GetDefaultBackgroundColor(); if (!String.IsNullOrEmpty(backgroundColorStyleStr)) { bodyStyleStr += String.Format("background-color:{0};", backgroundColorStyleStr); } } } //else if (EnableLightBackgroundColor) //{ // if (!bodyStyleStr.Contains("background-color")) // { // string backgroundColorStyleStr = GlobalConfig.GetLightBackgroundColor(PageManager.Instance.Theme.ToString()); // bodyStyleStr += String.Format("background-color:{0};", backgroundColorStyleStr); // } //} OB.AddProperty("bodyStyle", bodyStyleStr); OB.AddProperty("border", ShowBorder); #endregion #region IconUrl if (!String.IsNullOrEmpty(IconUrl)) { // Window控件的特殊处理在Window控件中 // 添加CSS样式 string className = String.Format("extaspnet_{0}_panelbase_icon", XID); AddStartupCSS(className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(IconUrl))); OB.AddProperty("iconCls", className); //// 下面这种方式不行,这个样式是要添加到Head中的,而不是最外层的DIV //AddExtraStyle("background", StyleUtil.GetNoRepeatBackgroundStyleValue(ResolveUrl(IconUrl))); } #endregion #region Width/Height // 对于Panel,如果宽度/高度没有定义 if (Width == Unit.Empty && AutoWidth) { OB.AddProperty("autoWidth", true); } if (Height == Unit.Empty && AutoHeight) { OB.AddProperty("autoHeight", true); } // 如果父控件是容器控件(不是ContentPanel),并且Layout != LayoutType.Container, // 则设置AutoWidth/AutoHeight都为false if (Parent is PanelBase) { PanelBase parent = Parent as PanelBase; if (!(parent is ContentPanel) && parent.Layout != Layout.Container) { OB.RemoveProperty("autoHeight"); OB.RemoveProperty("autoWidth"); } } if (AutoScroll) { OB.AddProperty("autoScroll", true); } #region old code //// 如果是 PageLayout 中的Panel,不能设置AutoWidth //if (Parent is PageLayout) //{ // // region // if (Region != Region_Default) OB.AddProperty(OptionName.Region, RegionTypeName.GetName(Region.Value)); //} //else //{ // // 对于Panel,如果宽度/高度没有定义,则使用自动宽度和高度 // if (Width == Unit.Empty) // { // OB.AddProperty(OptionName.AutoWidth, true); // } // if (Height == Unit.Empty) // { // OB.AddProperty(OptionName.AutoHeight, true); // } //} //// 如果父控件是容器控件,并且Layout=Fit,则设置AutoWidth/AutoHeight都为false //if (Parent is PanelBase) //{ // PanelBase parentPanel = Parent as PanelBase; // if (parentPanel.Layout == LayoutType.Fit // || parentPanel.Layout == LayoutType.Anchor // || parentPanel.Layout == LayoutType.Border) // { // OB.RemoveProperty(OptionName.AutoHeight); // OB.RemoveProperty(OptionName.AutoWidth); // } //} #endregion #endregion #region EnableIFrame if (EnableIFrame) { #region old code //string iframeJsContent = String.Empty; //string frameUrl = ResolveUrl(IFrameUrl); //JsObjectBuilder iframeBuilder = new JsObjectBuilder(); //if (IFrameDelayLoad) //{ // iframeBuilder.AddProperty(OptionName.Src, "#"); //} //else //{ // iframeBuilder.AddProperty(OptionName.Src, frameUrl); //} //iframeBuilder.AddProperty(OptionName.LoadMask, false); //iframeJsContent += String.Format("var {0}=new Ext.ux.ManagedIFrame('{0}',{1});", IFrameID, iframeBuilder.ToString()); //if (IFrameDelayLoad) //{ // iframeJsContent += String.Format("{0}_url='{1}';", IFrameID, frameUrl); //} //iframeJsContent += "\r\n"; //AddStartupScript(this, iframeJsContent); #endregion // 注意: // 如下依附于现有对象的属性名称的定义规则:x_property1 // 存储于当前对象实例中 OB.AddProperty("x_iframe", true); OB.AddProperty("x_iframe_url", IFrameUrl); OB.AddProperty("x_iframe_name", IFrameName); // 如果定义了IFrameUrl,则直接写到页面中,否则先缓存到此对象中 if (!String.IsNullOrEmpty(IFrameUrl)) { //_writeIframeToHtmlDocument = true; OB.AddProperty("x_iframe_loaded", true); // 直接添加iframe属性 OB.AddProperty("html", String.Format("<iframe src=\"{0}\" name=\"{1}\" frameborder=\"0\" style=\"height:100%;width:100%;overflow:auto;\"></iframe>", IFrameUrl, IFrameName)); } else { //_writeIframeToHtmlDocument = false; OB.AddProperty("x_iframe_loaded", false); } #region old code //// If current panel is Tab, then process the IFrameDelayLoad property. //Tab tab = this as Tab; //if (tab != null && tab.IFrameDelayLoad) //{ // // 如果是Tab,并且此Tab不是激活的,则不添加iframe // //_writeIframeToHtmlDocument = false; // OB.AddProperty("box_property_iframe_loaded", false); //} //else //{ // // 如果定义了IFrameUrl,则直接写到页面中,否则先缓存到此对象中 // if (!String.IsNullOrEmpty(IFrameUrl)) // { // //_writeIframeToHtmlDocument = true; // OB.AddProperty("box_property_iframe_loaded", true); // // 直接添加iframe属性 // OB.AddProperty("html", String.Format("<iframe src=\"{0}\" name=\"{1}\" frameborder=\"0\" style=\"height:100%;width:100%;overflow:auto;\"></iframe>", IFrameUrl, IFrameName)); // } // else // { // //_writeIframeToHtmlDocument = false; // OB.AddProperty("box_property_iframe_loaded", false); // } //} #endregion } #endregion #region RoundBorder //if (RoundBorder) OB.AddProperty(OptionName.Frame, true); #endregion #region EnableLargeHeader if (EnableLargeHeader) { OB.AddProperty("cls", "box-panel-big-header"); } #endregion #region remove fx // 关闭折叠时特效 OB.AddProperty("animCollapse", false); #endregion #region ContentEl //string finallyScript = String.Empty; if (RenderChildrenAsContent) { OB.AddProperty("contentEl", ContentID); // 在页面元素渲染完成后,才显示容器控件的内容 string renderScript = String.Format("Ext.get('{0}').show();", ContentID); OB.Listeners.AddProperty("render", "function(component){" + renderScript + "}", true); //string beforerenderScript = String.Format("Ext.get('{0}').setStyle('display','');", ChildrenContentID); //OB.Listeners.AddProperty("beforerender", "function(component){" + beforerenderScript + "}", true); // 这一段的逻辑(2008-9-1): // 如果是页面第一次加载 + 此Panel在Tab中 + 此Tab不是当前激活Tab + 此Tab的TabStrip启用了延迟加载 // 那么在页面加载完毕后,把此Panel给隐藏掉,等此Panel渲染到页面中时再显示出来 Tab tab = ControlUtil.FindParentControl(this, typeof(Tab)) as Tab; if (tab != null) { TabStrip tabStrip = tab.Parent as TabStrip; if (tabStrip.EnableDeferredRender && tabStrip.Tabs[tabStrip.ActiveTabIndex] != tab) { // 页面第一次加载时,在显示(控件的render事件)之前要先隐藏 AddStartupAbsoluteScript(String.Format("Ext.get('{0}').setStyle('display','none');", ContentID)); } } } #endregion }