Web Custom Control Problem
-
Hi All I have problem regarding WebCustom Control I am trying to develop a generic WebCustomControl for searching purpose. What i am trying to do is to pass UI Controls such as labels textboxes etc from the hosting page to the webcustom control. I have a method in WebCustomControl Class that add these control to the Control Collection of the WebCustomControl. The logic of the method is public void AddControls(Controls[] UIControls) { foreach (Control control in UIControls) { this.Controls.Add(control ); } } The Method is called from the Hosting Page as TextBox txt1 = new TextBox(); txt1.ID = "txtname"; Control[] c ={ txt1}; search.AddControls(c); I creat a control array and store my textbox in it i then pass the array to the method of webcustom control. Now the problem is that when render method of the control is called the control collection of webcutomcontrol lost its value. the logic of RenderContents is as protected override void RenderContents(HtmlTextWriter output) { foreach (Control control in UIControls) { control .RenderControl(output); } } :doh:This is fairly simple but i don't know where the problem is Any assistance will be appreciated Regards Faiq shah Afridi