protected override void OnFirstPreRender() { base.OnFirstPreRender(); #region Options //// 默认Layout //OB.AddProperty(OptionName.Layout, LayoutTypeName.GetName(Layout)); // 必须设置位置 OB.AddProperty("region", PositionHelper.GetName(Position)); if (!String.IsNullOrEmpty(Margins)) { OB.AddProperty("margins", Margins); } if (MinSize != Unit.Empty) { OB.AddProperty("minSize", MinSize.Value); } if (MaxSize != Unit.Empty) { OB.AddProperty("maxSize", Width.Value); } if (Split) { OB.AddProperty("split", true); } if (EnableSplitTip) { OB.AddProperty("useSplitTips", true); if (EnableCollapse) { if (!String.IsNullOrEmpty(CollapsibleSplitTip)) { OB.AddProperty("collapsibleSplitTip", CollapsibleSplitTip); } } else { if (!String.IsNullOrEmpty(SplitTip)) { OB.AddProperty("splitTip", SplitTip); } } } if (CollapseMode == CollapseMode.Mini) { OB.AddProperty("collapseMode", CollapseModeName.GetName(CollapseMode)); } if (!String.IsNullOrEmpty(CMargins)) { OB.AddProperty("cmargins", CMargins); } #endregion #region oldcode //if (!String.IsNullOrEmpty(ContentPlaceHolderId)) //{ // // 取得ContentPlaceHolder // Control hoderControl = ControlUtil.FindControl(Page, ContentPlaceHolderId); // // Clear Items // OB.RemoveProperty(OptionName.Items); // // 内容页面的控件列表 // foreach (Control c in hoderControl.Controls) // { // ControlBase component = c as ControlBase; // if (component != null) // { // component.RenderImmediately = false; // component.RefParentControl = this; // FineUI.PanelBase panel = component as FineUI.PanelBase; // if (panel != null) // { // panel.AutoHeight = false; // panel.AutoWidth = false; // } // } // } // AddItemsToOB(hoderControl.Controls); // #region old code // //// 这中改变控件层级的做法不对 // //// 取得 ContentPlaceHolder 下面的所有控件 // //List<ControlBase> componentList = new List<ControlBase>(); // //for (int i = 0, count = hoderControl.Controls.Count; i < count; i++) // //{ // // ControlBase component = hoderControl.Controls[i] as ControlBase; // // if (component != null) // // { // // componentList.Add(component); // // } // //} // //// 把这些控件添加到 本控件的子控件 // //foreach (ControlBase c in componentList) // //{ // // c.RenderImmediately = false; // // Controls.Add(c); // //} // //// Add Items // //AddItemsToOB(); // #endregion //} #endregion #region oldcode //if (!String.IsNullOrEmpty(SplitColor)) //{ // AddPageFirstLoadAbsoluteScript(String.Format("Ext.get('{0}-xsplit').setStyle('background-color','{1}');", ClientID, SplitColor), 1000); //} //string renderScript = String.Empty; //if (!String.IsNullOrEmpty(SplitColor)) //{ // renderScript += String.Format("Ext.get('{0}-xsplit').setStyle('background-color','{1}');", ClientID, SplitColor); //} //OB.Listeners.AddProperty("render", "function(component){" + renderScript + "}", true); #endregion string jsContent = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString()); AddStartupScript(jsContent); }
/// <summary> /// 渲染 HTML 之前调用(页面第一次加载或者普通回发) /// </summary> protected override void OnFirstPreRender() { base.OnFirstPreRender(); if (Width != Unit.Empty) { OB.AddProperty("width", Width.Value); } if (Height != Unit.Empty) { OB.AddProperty("height", Height.Value); } #region Controls in Layout Container parentControl = GetParentControl() as Container; if (parentControl != null) { if (parentControl.Layout == Layout.Anchor) { // 如果父节点是Anchor布局 if (!String.IsNullOrEmpty(AnchorValue)) { OB.AddProperty("anchor", AnchorValue); } } else if (parentControl.Layout == Layout.Column) { if (!String.IsNullOrEmpty(ColumnWidth)) { string columnWidth = StringUtil.ConvertPercentageToDecimalString(ColumnWidth); // 1.00 在IE下会有BUG,把1.00转换为0.999 if (columnWidth == "1.00") { columnWidth = "0.999"; } OB.AddProperty("columnWidth", columnWidth, true); } } else if (parentControl.Layout == Layout.Absolute) { if (AbsoluteX != Unit.Empty) { OB.AddProperty("x", AbsoluteX.Value); } if (AbsoluteY != Unit.Empty) { OB.AddProperty("y", AbsoluteY.Value); } } else if (parentControl.Layout == Layout.Table) { if (TableRowspan != 1) { OB.AddProperty("rowspan", TableRowspan); } if (TableColspan != 1) { OB.AddProperty("colspan", TableColspan); } } else if (parentControl.Layout == Layout.HBox || parentControl.Layout == Layout.VBox) { if (BoxFlex != 0) { OB.AddProperty("flex", BoxFlex); } //// 用户可能会设置 BoxMargin="0" 来覆盖 BoxConfigChildMargin 属性。 //if (BoxMargin != "") //{ // OB.AddProperty("margins", BoxMargin); //} } else if (parentControl.Layout == Layout.Region) { OB.AddProperty("region", PositionHelper.GetName(RegionPosition)); if (RegionSplit) { OB.AddProperty("split", true); } } } #endregion }