/// <summary> /// 创建行控件 /// </summary> /// <param name="field">字段信息</param> /// <returns>行控件</returns> protected Control CreateItem(We7Control control) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell c = new HtmlTableCell("TH"); HtmlGenericControl lable = new HtmlGenericControl("strong"); lable.InnerHtml = control.Label + ":"; c.Controls.Add(lable); row.Cells.Add(c); c = new HtmlTableCell(); We7Control ctr = control.Clone() as We7Control; if (!EnableControls.Contains(ctr.Type)) { ctr.Type = "Text"; } FieldControl fc = UIHelper.GetControl(ctr); fc.IsEdit = IsEdit; c.Controls.Add(fc); row.Cells.Add(c); row.Style.Add("display", control.Visible ? "" : "none"); return(row); }
public void InitLayout(PanelContext ctx) { PanelContext = ctx; if (!IsInitialized) { if (IsViewer) { if (!String.IsNullOrEmpty(PanelContext.Panel.EditInfo.ViewerCss)) { HtmlLink link = new HtmlLink(); link.Href = PanelContext.Panel.EditInfo.ViewerCss; link.Attributes["type"] = "text/css"; link.Attributes["rel"] = "stylesheet"; Page.Header.Controls.Add(link); } } else { if (!String.IsNullOrEmpty(PanelContext.Panel.EditInfo.EditCss)) { HtmlLink link = new HtmlLink(); link.Href = PanelContext.Panel.EditInfo.EditCss;; link.Attributes["type"] = "text/css"; link.Attributes["rel"] = "stylesheet"; Page.Header.Controls.Add(link); } } IsInitialized = true; } foreach (We7Control ctr in Panel.EditInfo.Controls) { if (IsViewer && String.Compare("ID", ctr.Name) == 0) { continue; } We7Control control = new We7Control(); foreach (PropertyInfo prop in ctr.GetType().GetProperties()) { prop.SetValue(control, prop.GetValue(ctr, null), null); } if (IsViewer && !EnableControls.Contains(control.Type)) { control.Type = "Text"; } PlaceHolder c = UIHelper.GetControl <PlaceHolder>("_" + control.ID, this); if (c != null) { c.Controls.Clear(); c.Controls.Add(UIHelper.GetControl(control)); } else { FieldControl fc = UIHelper.GetControl <FieldControl>(control.ID, this); if (UIHelper.GetControl <FieldControl>(control.ID, this) != null) { Controls.Remove(fc); } Controls.Add(UIHelper.GetControl(control)); } } }