how to put two textboxes under each other?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cas

    #1

    how to put two textboxes under each other?

    Hi,

    I create two textboxes and two labels.
    My problem is that: i want to get them under each other instead of beside
    each other.
    My second problem is that i want to have more spaces between the label and
    the textbox.
    Is there a way to do that?
    Thanks
    Cas

    Dim b As New Label
    b.Text = "label" & Space(7) 'space doesn't work
    form1.Controls. Add(b)
    Dim a = New TextBox
    form1.Controls. Add(a)

    Dim bb As New Label
    bb.Text = "label" & Space(7)
    form1.Controls. Add(bb)
    Dim aa = New TextBox
    form1.Controls. Add(aa)




  • Mythran

    #2
    Re: how to put two textboxes under each other?



    "Cas" <cas@qscq.opwro te in message
    news:eqFf7wT#GH A.4708@TK2MSFTN GP05.phx.gbl...
    Hi,
    >
    I create two textboxes and two labels.
    My problem is that: i want to get them under each other instead of beside
    each other.
    My second problem is that i want to have more spaces between the label and
    the textbox.
    Is there a way to do that?
    Thanks
    Cas
    >
    Dim b As New Label
    b.Text = "label" & Space(7) 'space doesn't work
    form1.Controls. Add(b)
    Dim a = New TextBox
    form1.Controls. Add(a)
    >
    Dim bb As New Label
    bb.Text = "label" & Space(7)
    form1.Controls. Add(bb)
    Dim aa = New TextBox
    form1.Controls. Add(aa)
    >
    >
    >
    >
    Is this for a windows app or for a web app?

    Mythran


    Comment

    • Cas

      #3
      Re: how to put two textboxes under each other?

      It's for using it with asp.net. I also don't know how to use the style
      "position: absolute" and left="..px" ...
      Thanks again

      "Mythran" <kip_potter@hot mail.comschreef in bericht
      news:et6d6VV%23 GHA.1200@TK2MSF TNGP02.phx.gbl. ..
      >
      >
      "Cas" <cas@qscq.opwro te in message
      news:eqFf7wT#GH A.4708@TK2MSFTN GP05.phx.gbl...
      >Hi,
      >>
      >I create two textboxes and two labels.
      >My problem is that: i want to get them under each other instead of beside
      >each other.
      >My second problem is that i want to have more spaces between the label
      >and the textbox.
      >Is there a way to do that?
      >Thanks
      >Cas
      >>
      > Dim b As New Label
      > b.Text = "label" & Space(7) 'space doesn't work
      > form1.Controls. Add(b)
      > Dim a = New TextBox
      > form1.Controls. Add(a)
      >>
      > Dim bb As New Label
      > bb.Text = "label" & Space(7)
      > form1.Controls. Add(bb)
      > Dim aa = New TextBox
      > form1.Controls. Add(aa)
      >>
      >>
      >>
      >>
      >
      Is this for a windows app or for a web app?
      >
      Mythran
      >
      >

      Comment

      • Mythran

        #4
        Re: how to put two textboxes under each other?



        "Cas" <cas@qscq.opwro te in message
        news:uqXdCvY#GH A.4980@TK2MSFTN GP04.phx.gbl...
        It's for using it with asp.net. I also don't know how to use the style
        "position: absolute" and left="..px" ...
        Thanks again
        >
        "Mythran" <kip_potter@hot mail.comschreef in bericht
        news:et6d6VV%23 GHA.1200@TK2MSF TNGP02.phx.gbl. ..
        >>
        >>
        >"Cas" <cas@qscq.opwro te in message
        >news:eqFf7wT#G HA.4708@TK2MSFT NGP05.phx.gbl.. .
        >>Hi,
        >>>
        >>I create two textboxes and two labels.
        >>My problem is that: i want to get them under each other instead of
        >>beside each other.
        >>My second problem is that i want to have more spaces between the label
        >>and the textbox.
        >>Is there a way to do that?
        >>Thanks
        >>Cas
        >>>
        >> Dim b As New Label
        >> b.Text = "label" & Space(7) 'space doesn't work
        >> form1.Controls. Add(b)
        >> Dim a = New TextBox
        >> form1.Controls. Add(a)
        >>>
        >> Dim bb As New Label
        >> bb.Text = "label" & Space(7)
        >> form1.Controls. Add(bb)
        >> Dim aa = New TextBox
        >> form1.Controls. Add(aa)
        >>>
        >>>
        >>>
        >>>
        >>
        >Is this for a windows app or for a web app?
        >>
        >Mythran
        >>
        >>
        >
        >
        Personally, I would use absolute positioning...i nstead, while dynamically
        adding the label controls, you need to add a LiteralControl in between the
        textbox and the label #2. The LiteralControl would contain a "<br>" tag ..

        HTH,
        Mythran


        Comment

        • André

          #5
          Re: how to put two textboxes under each other?

          My problrm is that i have to create a unknown number of texboxes, and labels
          (the amount is fetched from a database), and i want them to be displayed
          more or less correctly ....

          "Mythran" <kip_potter@hot mail.comschreef in bericht
          news:ua34f0d%23 GHA.4196@TK2MSF TNGP03.phx.gbl. ..
          >
          >
          "Cas" <cas@qscq.opwro te in message
          news:uqXdCvY#GH A.4980@TK2MSFTN GP04.phx.gbl...
          >It's for using it with asp.net. I also don't know how to use the style
          >"position: absolute" and left="..px" ...
          >Thanks again
          >>
          >"Mythran" <kip_potter@hot mail.comschreef in bericht
          >news:et6d6VV%2 3GHA.1200@TK2MS FTNGP02.phx.gbl ...
          >>>
          >>>
          >>"Cas" <cas@qscq.opwro te in message
          >>news:eqFf7wT# GHA.4708@TK2MSF TNGP05.phx.gbl. ..
          >>>Hi,
          >>>>
          >>>I create two textboxes and two labels.
          >>>My problem is that: i want to get them under each other instead of
          >>>beside each other.
          >>>My second problem is that i want to have more spaces between the label
          >>>and the textbox.
          >>>Is there a way to do that?
          >>>Thanks
          >>>Cas
          >>>>
          >>> Dim b As New Label
          >>> b.Text = "label" & Space(7) 'space doesn't work
          >>> form1.Controls. Add(b)
          >>> Dim a = New TextBox
          >>> form1.Controls. Add(a)
          >>>>
          >>> Dim bb As New Label
          >>> bb.Text = "label" & Space(7)
          >>> form1.Controls. Add(bb)
          >>> Dim aa = New TextBox
          >>> form1.Controls. Add(aa)
          >>>>
          >>>>
          >>>>
          >>>>
          >>>
          >>Is this for a windows app or for a web app?
          >>>
          >>Mythran
          >>>
          >>>
          >>
          >>
          >
          Personally, I would use absolute positioning...i nstead, while dynamically
          adding the label controls, you need to add a LiteralControl in between the
          textbox and the label #2. The LiteralControl would contain a "<br>" tag
          ..
          >
          HTH,
          Mythran
          >
          >

          Comment

          • Mythran

            #6
            Re: how to put two textboxes under each other?



            "Mythran" <kip_potter@hot mail.comwrote in message
            news:ua34f0d#GH A.4196@TK2MSFTN GP03.phx.gbl...
            >
            >
            "Cas" <cas@qscq.opwro te in message
            news:uqXdCvY#GH A.4980@TK2MSFTN GP04.phx.gbl...
            >It's for using it with asp.net. I also don't know how to use the style
            >"position: absolute" and left="..px" ...
            >Thanks again
            >>
            >"Mythran" <kip_potter@hot mail.comschreef in bericht
            >news:et6d6VV%2 3GHA.1200@TK2MS FTNGP02.phx.gbl ...
            >>>
            >>>
            >>"Cas" <cas@qscq.opwro te in message
            >>news:eqFf7wT# GHA.4708@TK2MSF TNGP05.phx.gbl. ..
            >>>Hi,
            >>>>
            >>>I create two textboxes and two labels.
            >>>My problem is that: i want to get them under each other instead of
            >>>beside each other.
            >>>My second problem is that i want to have more spaces between the label
            >>>and the textbox.
            >>>Is there a way to do that?
            >>>Thanks
            >>>Cas
            >>>>
            >>> Dim b As New Label
            >>> b.Text = "label" & Space(7) 'space doesn't work
            >>> form1.Controls. Add(b)
            >>> Dim a = New TextBox
            >>> form1.Controls. Add(a)
            >>>>
            >>> Dim bb As New Label
            >>> bb.Text = "label" & Space(7)
            >>> form1.Controls. Add(bb)
            >>> Dim aa = New TextBox
            >>> form1.Controls. Add(aa)
            >>>>
            >>>>
            >>>>
            >>>>
            >>>
            >>Is this for a windows app or for a web app?
            >>>
            >>Mythran
            >>>
            >>>
            >>
            >>
            >
            Personally, I would use absolute positioning...i nstead, while dynamically
            adding the label controls, you need to add a LiteralControl in between the
            textbox and the label #2. The LiteralControl would contain a "<br>" tag
            ..
            >
            HTH,
            Mythran
            >
            >
            That should read, "Personally , I would NOT use ..."

            :P

            Mythran


            Comment

            • Mythran

              #7
              Re: how to put two textboxes under each other?



              "André" <svs@sdv.sdwrot e in message
              news:eNZxYPe#GH A.896@TK2MSFTNG P03.phx.gbl...
              My problrm is that i have to create a unknown number of texboxes, and
              labels (the amount is fetched from a database), and i want them to be
              displayed more or less correctly ....
              >

              How do you mean "more or less correctly..."? Do you want them displayed
              top-down or left-right? Do you want something like:

              Label : TextBox
              Label : TextBox
              ??

              If so, then the following should work:

              Dim frm As HtmlForm = Me.FindControl( "form1") ' gave the form an id
              of 'form1'
              Dim lbl As Label
              Dim lit As LiteralControl
              Dim txt As TextBox

              ' Create first control set.
              lbl = New Label()
              lbl.Text = "Label #1: "
              frm.Controls.Ad d(lbl)
              txt = New TextBox()
              txt.ID = "txtBox1"
              frm.Controls.Ad d(txt)
              lit = New LiteralControl( "<br>")
              frm.Controls.Ad d(lit)

              ' Create second control set.
              lbl = New Label()
              lbl.Text = "Label #2: "
              frm.Controls.Ad d(lbl)
              txt = New TextBox()
              txt.ID = "txtBox2"
              frm.Controls.Ad d(txt)
              lit = New LiteralControl( "<br>")
              frm.Controls.Ad d(lit)

              HTH :)

              Mythran


              Comment

              • Göran Andersson

                #8
                Re: how to put two textboxes under each other?

                I would put the label and the field in a block container, i.e. a div
                tag. I would set a class on the div tag so that I could use CSS to
                format them.

                Resulting HTML:

                <div class="FormItem ">
                <label for="someId"></label>
                <input type="text" id="someId" />
                </div>

                CSS:

                ..FormItem { margin: 3px 0; }
                ..FormItem label { float: left; width: 150px; }
                ..FormItem input { float: left; width: 150px; }

                I don't think that the Label control creates a real label tag, though.
                You would have to use an HtmlGenericCont rol for that, just as for the
                div tag.

                Cas wrote:
                Hi,
                >
                I create two textboxes and two labels.
                My problem is that: i want to get them under each other instead of beside
                each other.
                My second problem is that i want to have more spaces between the label and
                the textbox.
                Is there a way to do that?
                Thanks
                Cas
                >
                Dim b As New Label
                b.Text = "label" & Space(7) 'space doesn't work
                form1.Controls. Add(b)
                Dim a = New TextBox
                form1.Controls. Add(a)
                >
                Dim bb As New Label
                bb.Text = "label" & Space(7)
                form1.Controls. Add(bb)
                Dim aa = New TextBox
                form1.Controls. Add(aa)
                >
                >
                >
                >

                Comment

                • Cas

                  #9
                  Re: how to put two textboxes under each other?

                  Thanks

                  "Göran Andersson" <guffa@guffa.co mschreef in bericht
                  news:ukJs1Qj%23 GHA.3352@TK2MSF TNGP03.phx.gbl. ..
                  >I would put the label and the field in a block container, i.e. a div tag. I
                  >would set a class on the div tag so that I could use CSS to format them.
                  >
                  Resulting HTML:
                  >
                  <div class="FormItem ">
                  <label for="someId"></label>
                  <input type="text" id="someId" />
                  </div>
                  >
                  CSS:
                  >
                  .FormItem { margin: 3px 0; }
                  .FormItem label { float: left; width: 150px; }
                  .FormItem input { float: left; width: 150px; }
                  >
                  I don't think that the Label control creates a real label tag, though. You
                  would have to use an HtmlGenericCont rol for that, just as for the div tag.
                  >
                  Cas wrote:
                  >Hi,
                  >>
                  >I create two textboxes and two labels.
                  >My problem is that: i want to get them under each other instead of beside
                  >each other.
                  >My second problem is that i want to have more spaces between the label
                  >and the textbox.
                  >Is there a way to do that?
                  >Thanks
                  >Cas
                  >>
                  > Dim b As New Label
                  > b.Text = "label" & Space(7) 'space doesn't work
                  > form1.Controls. Add(b)
                  > Dim a = New TextBox
                  > form1.Controls. Add(a)
                  >>
                  > Dim bb As New Label
                  > bb.Text = "label" & Space(7)
                  > form1.Controls. Add(bb)
                  > Dim aa = New TextBox
                  > form1.Controls. Add(aa)
                  >>
                  >>
                  >>

                  Comment

                  • Cas

                    #10
                    Re: how to put two textboxes under each other?

                    Thanks

                    "Mythran" <kip_potter@hot mail.comschreef in bericht
                    news:uVlEyfe%23 GHA.4704@TK2MSF TNGP04.phx.gbl. ..
                    >
                    >
                    "André" <svs@sdv.sdwrot e in message
                    news:eNZxYPe#GH A.896@TK2MSFTNG P03.phx.gbl...
                    >My problrm is that i have to create a unknown number of texboxes, and
                    >labels (the amount is fetched from a database), and i want them to be
                    >displayed more or less correctly ....
                    >>
                    >
                    >
                    How do you mean "more or less correctly..."? Do you want them displayed
                    top-down or left-right? Do you want something like:
                    >
                    Label : TextBox
                    Label : TextBox
                    ??
                    >
                    If so, then the following should work:
                    >
                    Dim frm As HtmlForm = Me.FindControl( "form1") ' gave the form an id
                    of 'form1'
                    Dim lbl As Label
                    Dim lit As LiteralControl
                    Dim txt As TextBox
                    >
                    ' Create first control set.
                    lbl = New Label()
                    lbl.Text = "Label #1: "
                    frm.Controls.Ad d(lbl)
                    txt = New TextBox()
                    txt.ID = "txtBox1"
                    frm.Controls.Ad d(txt)
                    lit = New LiteralControl( "<br>")
                    frm.Controls.Ad d(lit)
                    >
                    ' Create second control set.
                    lbl = New Label()
                    lbl.Text = "Label #2: "
                    frm.Controls.Ad d(lbl)
                    txt = New TextBox()
                    txt.ID = "txtBox2"
                    frm.Controls.Ad d(txt)
                    lit = New LiteralControl( "<br>")
                    frm.Controls.Ad d(lit)
                    >
                    HTH :)
                    >
                    Mythran
                    >
                    >

                    Comment

                    Working...