VIew State in CustomControl
-
Hi All I have a problem with maintaining view state in WebCustomControl. The problem is that i want to create a generic search control. All controls that is used in search criteria is passed from hosting page e.g TextBox txt1 = new TextBox(); TextBox txt2 = new TextBox(); TextBox txt3 = new TextBox(); Control[] c ={ txttest, txt1, txt2, txt3 }; SearchControl.WebCustomControl1.AddControls(c); Where Add control is Satic method in webcustom control its code is as public static void AddControls(Control[] Controls) { UIControls = Controls; } where UIControls is static Control array defined in Custom control I then Render the control as protected override void RenderContents(HtmlTextWriter output) { output.Write(""); for (int i = 0; i < UIControls.Length; i++) { output.Write(" "); output.Write(" "); output.Write(" "); } output.Write(" "); output.Write(" "); output.Write(" "); output.Write("
"); UIControls[i].RenderControl(output); output.Write("
"); output.Write(""); output.Write(""); output.Write("
"); } Now the problem is that when i access any of the control, its value is lost! Any one that can help me plz regards