Hello to all the smart people,
I'm trying to create a composite control which include nested controls from the great Ajax Dev.
I overcame a lot of issues and can be helpful in some but my latest problem doesn't seem to disappeared.
I can't trigger the ITemplate that i declared (maybe improperly?) to show first a Gif on the progress and afterwords the calculated information from the database.
the code is as followed:
can someone please help me?Code:[DefaultProperty("Text")] [ToolboxData("<{0}:SingleRecControl runat=server>")] [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class SingleRecControl : CompositeControl { private ScriptManager sm = new ScriptManager(); UpdateProgress progBar = new UpdateProgress(); UpdatePanel ratePanel = new UpdatePanel(); ControlValueTrigger trig = new ControlValueTrigger(); public Label ItemName = new Label(); private Style[] objStyle = new Style[3]; protected override void CreateChildControls() { base.CreateChildControls(); Controls.Clear(); sm.EnablePartialRendering = false; sm.EnableViewState = true; sm.AppRelativeTemplateSourceDirectory = "~/Default.aspx"; sm.ID = "cc2"; sm.EnablePartialRendering = true; btn.Visible = false; btn.CommandName = "NEXT"; btn.ID = "Test"; btn.UseSubmitBehavior = false; btn.Text = "Test"; objStyle[0] = new Style(); ItemName = new Label(); ItemName.BorderStyle = objStyle[0].BorderStyle; ItemName.BorderWidth = objStyle[0].BorderWidth; ItemName.BorderColor = objStyle[0].BorderColor; ItemName.Width = objStyle[0].Width; ItemName.Height = objStyle[0].Height; ItemName.ID = "lblCheck"; ItemName.Text = "bl"; ItemName.Visible = true; this.Controls.Add(ItemName); progBar.ProgressTemplate = new BarGif("blablablablablabla"); progBar.ID = "GifBar"; ratePanel.ContentTemplate = new RemTemp(); ratePanel.ID = "RatePanel"; trig.ControlID = this.ID + "_" + ItemName.ID; trig.PropertyName = "Text"; this.ratePanel.Triggers.Add(trig); this.Controls.Add(sm); this.Controls.Add(progBar); this.Controls.Add(ratePanel); } protected override void Render(HtmlTextWriter writer) { base.Render(writer); this.Controls.Clear(); sm.RenderControl(writer); progBar.RenderControl(writer); ratePanel.RenderControl(writer); ItemName.RenderControl(writer); } public class BarGif : TemplateControl, ITemplate { private string _barPic; public BarGif(string template) { this._barPic = template; } public void InstantiateIn(Control container) { LiteralControl lc = new LiteralControl("<img src=&quat;"+this._barPic+"&quat;/>"); container.Controls.Add(lc); }} public class RemTemp : SingleRecControl, ITemplate { public event System.EventHandler ProssFinished; private SophiaClass.DemoDbAcc dbAcc=new DemoDbAcc(); private DataTable itemRateTable=new DataTable(); public string userNam = "31"; public RemTemp() { RecomTableBuilder(); } protected void RecomTableBuilder() { dbAcc = new DemoDbAcc(); itemRateTable = dbAcc.GetRateTable(int.Parse(userNam)); if (!this.DesignMode) Thread.Sleep(4000); ItemName.Text = recItem.ItemName; ItemDesc.Text = recItem.ItemDescript; ItemPhoto.ImageUrl = recItem.ItemPhotoPath; } private Items MakeArrRec(DataTable table, int index) { recItem = new Items(); recItem.ItemID = table.Rows[index]["id"].ToString(); recItem.ItemName = table.Rows[index]["itemname"].ToString(); recItem.ItemDescript = table.Rows[index]["itemDesc"].ToString(); recItem.ItemPhotoPath = table.Rows[index]["itemPhotoPath"].ToString(); return recItem; } }}
please advise.......
i feel so lucky to have someone to share my troubles
Lior


Reply With Quote


Bookmarks