protected void CreateControls() { this.Controls.Clear(); //this.DataSource = ContainerDAL.GetContainerByIdContainer(this.IdContainer); this.DataSource = WidGetDAL.GetWidGetsByIdContainer(this.IdContainer); WidGet widget = null; if (this.DataSource != null && this.DataSource.Count > 0) { widget = this.DataSource[0]; // TODO más de un widget por container //Container container = this.DataSource[0]; //gadget = (Gadget)Activator.CreateInstance(Type.GetType(container.Type)); //gadget.ID = string.Format("GADGET_{0}_{1}", container.IdContainer, container.ID); //gadget.EditMode = this.EditMode; //gadget.IdContainer = container.IdContainer; gadget = (Gadget)Activator.CreateInstance(Type.GetType(widget.Type)); gadget.ID = string.Format("GADGET_{0}_{1}", widget.IdContainer, widget.ID); gadget.Keys = new WidgetKeys(widget.ID, widget.IdContainer, widget.Type, 0); //TODO POS gadget.DataXML = widget.Data; gadget.EditMode = this.EditMode; this.Controls.Add(gadget); if (this.EditMode) { JQueryManager jman = new JQueryManager(); jman.RegisterJQuerys(this.Page); } } if (this.EditMode) { TopRibbon = new ContainerRibbon(this.IdContainer, widget != null ? widget.ID : (Nullable<int>) null); TopRibbon.AddGadget += new GadgetContainerEventHandler(TopRibbon_AddGadget); this.Controls.Add(TopRibbon); } if (this.PageEditMode) { btnEditar = new ImageLinkButton(); string texto = this.EditMode ? "Detener Edicion" : "Editar"; btnEditar.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(GadgetContainer), "Inventio.Engine.Resources.img.engine.png"); btnEditar.ImageWidth = new Unit(16, UnitType.Pixel); btnEditar.Text = texto; btnEditar.Click += new EventHandler(btnEditar_Click); this.Controls.Add(btnEditar); } }
private void RenderGadget(System.Web.UI.HtmlTextWriter writer, Gadget gadget) { writer.WriteLine("<div>"); gadget.RenderControl(writer); writer.WriteLine("</div>"); }