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. Add Control

Add Control

Scheduled Pinned Locked Moved ASP.NET
jsonhelp
10 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.
  • V Offline
    V Offline
    vengaqua
    wrote on last edited by
    #1

    I am doing this and only the last textbox is there and rest of them are not there. Please help me out friends its very urgent. Txt.ID = "SubmitBtn1" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt) PlaceHolder1.Controls.Add(New LiteralControl("
    ")) Txt.ID = "SubmitBtn2" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt) PlaceHolder1.Controls.Add(New LiteralControl("
    ")) Txt.ID = "SubmitBtn3" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt) PlaceHolder1.Controls.Add(New LiteralControl("
    ")) Txt.ID = "SubmitBtn4" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt)

    Mohinder Singh

    M 1 Reply Last reply
    0
    • V vengaqua

      I am doing this and only the last textbox is there and rest of them are not there. Please help me out friends its very urgent. Txt.ID = "SubmitBtn1" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt) PlaceHolder1.Controls.Add(New LiteralControl("
      ")) Txt.ID = "SubmitBtn2" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt) PlaceHolder1.Controls.Add(New LiteralControl("
      ")) Txt.ID = "SubmitBtn3" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt) PlaceHolder1.Controls.Add(New LiteralControl("
      ")) Txt.ID = "SubmitBtn4" Txt.TextMode = TextBoxMode.MultiLine PlaceHolder1.Controls.Add(Txt)

      Mohinder Singh

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      You need to create a new textbox everytime you plan to add one so before the Txt.ID portion of each section call for a new textbox Txt = New Textbox.


      CleaKO

      "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
      "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

      J 1 Reply Last reply
      0
      • M Marcus J Smith

        You need to create a new textbox everytime you plan to add one so before the Txt.ID portion of each section call for a new textbox Txt = New Textbox.


        CleaKO

        "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
        "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

        J Offline
        J Offline
        joon vh
        wrote on last edited by
        #3

        I think even that won't do the trick. Shouldn't you actually declare an entirely new variable everytime? TextBox txt1 = new TextBox(); TextBox txt2 = new TextBox(); TextBox txt3 = new TextBox(); TextBox txt4 = new TextBox(); TextBox txt5 = new TextBox(); ...


        public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

        M V 2 Replies Last reply
        0
        • J joon vh

          I think even that won't do the trick. Shouldn't you actually declare an entirely new variable everytime? TextBox txt1 = new TextBox(); TextBox txt2 = new TextBox(); TextBox txt3 = new TextBox(); TextBox txt4 = new TextBox(); TextBox txt5 = new TextBox(); ...


          public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

          M Offline
          M Offline
          Marcus J Smith
          wrote on last edited by
          #4

          Once it's added no. I do this often when populating a datatable with a datarow. You use the same variable, next loop set it to new again then populate and add. -- modified at 11:43 Monday 19th March, 2007


          CleaKO

          "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
          "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

          J 1 Reply Last reply
          0
          • M Marcus J Smith

            Once it's added no. I do this often when populating a datatable with a datarow. You use the same variable, next loop set it to new again then populate and add. -- modified at 11:43 Monday 19th March, 2007


            CleaKO

            "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
            "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

            J Offline
            J Offline
            joon vh
            wrote on last edited by
            #5

            I learned something today!


            public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

            M 1 Reply Last reply
            0
            • J joon vh

              I learned something today!


              public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

              M Offline
              M Offline
              Marcus J Smith
              wrote on last edited by
              #6

              Although it may be easier to follow in the case of the OP if different names are used that match the ID given but it isnt required.


              CleaKO

              "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
              "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

              J 1 Reply Last reply
              0
              • M Marcus J Smith

                Although it may be easier to follow in the case of the OP if different names are used that match the ID given but it isnt required.


                CleaKO

                "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
                "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

                J Offline
                J Offline
                joon vh
                wrote on last edited by
                #7

                I usually use this in a loop, and then I put the declaration in the loop too. Is this good practice? Or is there no performance difference. -- modified at 12:08 Monday 19th March, 2007 I threw together this code: class Program { static void Main(string[] args) { Stopwatch sw = new Stopwatch(); sw.Start(); test1(); sw.Stop(); Console.WriteLine(sw.Elapsed); sw.Reset(); sw.Start(); test2(); sw.Stop(); Console.WriteLine(sw.Elapsed); Console.Read(); } static void test1() { String testString; for (int i = 0; i < 50000000; i++) { testString = i.ToString(); } } static void test2() { for (int i = 0; i < 50000000; i++) { String testString; testString = i.ToString(); } } } pretty fun (clogs for about 17 secs on my pc)... but not really conclusive. I asked a MSIL guru about it. You probably don't care even half as much as I do, but I like these kinds of perf. things.


                public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

                V 1 Reply Last reply
                0
                • J joon vh

                  I usually use this in a loop, and then I put the declaration in the loop too. Is this good practice? Or is there no performance difference. -- modified at 12:08 Monday 19th March, 2007 I threw together this code: class Program { static void Main(string[] args) { Stopwatch sw = new Stopwatch(); sw.Start(); test1(); sw.Stop(); Console.WriteLine(sw.Elapsed); sw.Reset(); sw.Start(); test2(); sw.Stop(); Console.WriteLine(sw.Elapsed); Console.Read(); } static void test1() { String testString; for (int i = 0; i < 50000000; i++) { testString = i.ToString(); } } static void test2() { for (int i = 0; i < 50000000; i++) { String testString; testString = i.ToString(); } } } pretty fun (clogs for about 17 secs on my pc)... but not really conclusive. I asked a MSIL guru about it. You probably don't care even half as much as I do, but I like these kinds of perf. things.


                  public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

                  V Offline
                  V Offline
                  vengaqua
                  wrote on last edited by
                  #8

                  if i add new control at runtime suppose three buttons how can i get the click event of these three buttons.

                  Mohinder Singh

                  1 Reply Last reply
                  0
                  • J joon vh

                    I think even that won't do the trick. Shouldn't you actually declare an entirely new variable everytime? TextBox txt1 = new TextBox(); TextBox txt2 = new TextBox(); TextBox txt3 = new TextBox(); TextBox txt4 = new TextBox(); TextBox txt5 = new TextBox(); ...


                    public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

                    V Offline
                    V Offline
                    vengaqua
                    wrote on last edited by
                    #9

                    if i do this way for the button then i get three buttons but how can i have the click event of these three buttons .

                    Mohinder Singh

                    J 1 Reply Last reply
                    0
                    • V vengaqua

                      if i do this way for the button then i get three buttons but how can i have the click event of these three buttons .

                      Mohinder Singh

                      J Offline
                      J Offline
                      joon vh
                      wrote on last edited by
                      #10

                      By setting the event in code. LinkButton.Click += new System.EventHandler(method); in VS2005 Intellisense does most of the thinking for you.


                      public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

                      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