Design Time Run time
-
Hi, At the design time, I have added 6 textbox on the webform. Thing I want to do, to add these textboxes an array at runtime. How can i do that? .....(the other webcontrols).............. protected System.Web.UI.WebControls.TextBox txt0; protected System.Web.UI.WebControls.TextBox txt1; protected System.Web.UI.WebControls.TextBox txt2; protected System.Web.UI.WebControls.TextBox txt3; protected System.Web.UI.WebControls.TextBox txt4; protected System.Web.UI.WebControls.TextBox txt5; .....(the other webcontrols).............. .... TextBox[] txtArray = new TextBox[6]; for (int i=0; i < txtArray.Length; i++) { txtArray[i] = ??????????;(Controls["txt"+i.ToString()]; dont working) } Thanks for your help... Savaş Külah savaskulah@msn.com
-
Hi, At the design time, I have added 6 textbox on the webform. Thing I want to do, to add these textboxes an array at runtime. How can i do that? .....(the other webcontrols).............. protected System.Web.UI.WebControls.TextBox txt0; protected System.Web.UI.WebControls.TextBox txt1; protected System.Web.UI.WebControls.TextBox txt2; protected System.Web.UI.WebControls.TextBox txt3; protected System.Web.UI.WebControls.TextBox txt4; protected System.Web.UI.WebControls.TextBox txt5; .....(the other webcontrols).............. .... TextBox[] txtArray = new TextBox[6]; for (int i=0; i < txtArray.Length; i++) { txtArray[i] = ??????????;(Controls["txt"+i.ToString()]; dont working) } Thanks for your help... Savaş Külah savaskulah@msn.com
hi, Your question is not at all clear... can you be clear in your requirement... Well... herez my guess... you have 6 textbox on your web form which you have added at design time... Now at run time you want the objects of these textboxes in an array... if it is so... then all you need to do is : ArrayList txtArray = new ArrayList(); txtArray.Add(txt0); txtArray.Add(txt1); . . . txtArray.Add(txt5); TextBox[] textColtn = (TextBox[])txtArray.ToArray(new TextBox().GetType()); Hope I have solved your problem... regards, Aryadip. Cheers !! and have a Funky day !!
-
hi, Your question is not at all clear... can you be clear in your requirement... Well... herez my guess... you have 6 textbox on your web form which you have added at design time... Now at run time you want the objects of these textboxes in an array... if it is so... then all you need to do is : ArrayList txtArray = new ArrayList(); txtArray.Add(txt0); txtArray.Add(txt1); . . . txtArray.Add(txt5); TextBox[] textColtn = (TextBox[])txtArray.ToArray(new TextBox().GetType()); Hope I have solved your problem... regards, Aryadip. Cheers !! and have a Funky day !!