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 at runtime

add control at runtime

Scheduled Pinned Locked Moved ASP.NET
8 Posts 4 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 able to add controls at runtime but i am not able to specify the height and width of the control.How can i do it ?

    Mohinder Singh

    C S 2 Replies Last reply
    0
    • V vengaqua

      I am able to add controls at runtime but i am not able to specify the height and width of the control.How can i do it ?

      Mohinder Singh

      C Offline
      C Offline
      ca8msm
      wrote on last edited by
      #2

      You should be able to. Please provide an example of what you've done.

      Mark, http://aspnetlibrary.com

      1 Reply Last reply
      0
      • V vengaqua

        I am able to add controls at runtime but i am not able to specify the height and width of the control.How can i do it ?

        Mohinder Singh

        S Offline
        S Offline
        Sandeep Akhare
        wrote on last edited by
        #3

        Its very simple you have height and width property to control e.g for TextBox TextBox txt = new TextBox(); txt.ID = "ControlID" txt.Width = 50; txt.Height = 23; panelSample.Controls.Add(txt); if you don't have then use style sheet i.e css file and give class name to cssClass property of the control

        Thanks and Regards Sandeep If you want something you never had, do something you have never done!

        R 1 Reply Last reply
        0
        • S Sandeep Akhare

          Its very simple you have height and width property to control e.g for TextBox TextBox txt = new TextBox(); txt.ID = "ControlID" txt.Width = 50; txt.Height = 23; panelSample.Controls.Add(txt); if you don't have then use style sheet i.e css file and give class name to cssClass property of the control

          Thanks and Regards Sandeep If you want something you never had, do something you have never done!

          R Offline
          R Offline
          RichardGrimmer
          wrote on last edited by
          #4

          sandeep akhare wrote:

          txt.Width = 50; txt.Height = 23;

          try: txt.Height = new Unit(UnitType.pixel, 50.00);

          "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

          S V 3 Replies Last reply
          0
          • R RichardGrimmer

            sandeep akhare wrote:

            txt.Width = 50; txt.Height = 23;

            try: txt.Height = new Unit(UnitType.pixel, 50.00);

            "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

            S Offline
            S Offline
            Sandeep Akhare
            wrote on last edited by
            #5

            OOPS thanks for corrections

            Thanks and Regards Sandeep If you want something you never had, do something you have never done!

            V 1 Reply Last reply
            0
            • R RichardGrimmer

              sandeep akhare wrote:

              txt.Width = 50; txt.Height = 23;

              try: txt.Height = new Unit(UnitType.pixel, 50.00);

              "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

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

              when i see the width of textbox in the property window it shows 245px. Px is for pixels.

              Mohinder Singh

              1 Reply Last reply
              0
              • R RichardGrimmer

                sandeep akhare wrote:

                txt.Width = 50; txt.Height = 23;

                try: txt.Height = new Unit(UnitType.pixel, 50.00);

                "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

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

                hi dear i am doing this but the textbox is not being shown in the form. Dim txt as textbox Txt = New TextBox Txt.ID = "SubmitBtn" Txt.TextMode = TextBoxMode.MultiLine Txt.Height = New Unit(UnitType.Pixel, 24.0) Txt.Width = New Unit(UnitType.Pixel, 250) PlaceHolder1.Controls.Add(Txt) I am using place holder. when i dont give any height and width i get the textbox but it is small. and i want a bigger textbox.

                Mohinder Singh

                1 Reply Last reply
                0
                • S Sandeep Akhare

                  OOPS thanks for corrections

                  Thanks and Regards Sandeep If you want something you never had, do something you have never done!

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

                  Please help me out dear i am not able to get the output .

                  Mohinder Singh

                  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