Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Design Time Run time

Design Time Run time

Scheduled Pinned Locked Moved ASP.NET
designquestioncomdata-structureshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    savaskulah
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • S savaskulah

      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

      A Offline
      A Offline
      Aryadip
      wrote on last edited by
      #2

      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 !!

      P 1 Reply Last reply
      0
      • A Aryadip

        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 !!

        P Offline
        P Offline
        p daddy
        wrote on last edited by
        #3

        You could save manually adding each textbox to the array by using FindControl: for(int i=0; i<6; i++) { txtArray.Add(FindControl("txt"+i)); } Hope this helps Paul

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups