Home All Groups Group Topic Archive Search About

how to put two textboxes under each other?

Author
26 Oct 2006 8:20 PM
Cas
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)

Author
26 Oct 2006 11:20 PM
Mythran
Show quote Hide quote
"Cas" <c**@qscq.op> wrote in message
news:eqFf7wT#GHA.4708@TK2MSFTNGP05.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
Author
27 Oct 2006 5:50 AM
Cas
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

Show quoteHide quote
"Mythran" <kip_pot***@hotmail.com> schreef in bericht
news:et6d6VV%23GHA.1200@TK2MSFTNGP02.phx.gbl...
>
>
> "Cas" <c**@qscq.op> wrote in message
> news:eqFf7wT#GHA.4708@TK2MSFTNGP05.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
>
>
Author
27 Oct 2006 3:32 PM
Mythran
Show quote Hide quote
"Cas" <c**@qscq.op> wrote in message
news:uqXdCvY#GHA.4980@TK2MSFTNGP04.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_pot***@hotmail.com> schreef in bericht
> news:et6d6VV%23GHA.1200@TK2MSFTNGP02.phx.gbl...
>>
>>
>> "Cas" <c**@qscq.op> wrote in message
>> news:eqFf7wT#GHA.4708@TK2MSFTNGP05.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...instead, 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
Author
27 Oct 2006 4:20 PM
André
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 ....

Show quoteHide quote
"Mythran" <kip_pot***@hotmail.com> schreef in bericht
news:ua34f0d%23GHA.4196@TK2MSFTNGP03.phx.gbl...
>
>
> "Cas" <c**@qscq.op> wrote in message
> news:uqXdCvY#GHA.4980@TK2MSFTNGP04.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_pot***@hotmail.com> schreef in bericht
>> news:et6d6VV%23GHA.1200@TK2MSFTNGP02.phx.gbl...
>>>
>>>
>>> "Cas" <c**@qscq.op> wrote in message
>>> news:eqFf7wT#GHA.4708@TK2MSFTNGP05.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...instead, 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
>
>
Author
27 Oct 2006 4:49 PM
Mythran
"André" <s**@sdv.sd> wrote in message
news:eNZxYPe#GHA.896@TK2MSFTNGP03.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.Add(lbl)
        txt = New TextBox()
        txt.ID = "txtBox1"
        frm.Controls.Add(txt)
        lit = New LiteralControl("<br>")
        frm.Controls.Add(lit)

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

HTH :)

Mythran
Author
28 Oct 2006 5:40 PM
Cas
Thanks

Show quoteHide quote
"Mythran" <kip_pot***@hotmail.com> schreef in bericht
news:uVlEyfe%23GHA.4704@TK2MSFTNGP04.phx.gbl...
>
>
> "André" <s**@sdv.sd> wrote in message
> news:eNZxYPe#GHA.896@TK2MSFTNGP03.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.Add(lbl)
>        txt = New TextBox()
>        txt.ID = "txtBox1"
>        frm.Controls.Add(txt)
>        lit = New LiteralControl("<br>")
>        frm.Controls.Add(lit)
>
>        ' Create second control set.
>        lbl = New Label()
>        lbl.Text = "Label #2: "
>        frm.Controls.Add(lbl)
>        txt = New TextBox()
>        txt.ID = "txtBox2"
>        frm.Controls.Add(txt)
>        lit = New LiteralControl("<br>")
>        frm.Controls.Add(lit)
>
> HTH :)
>
> Mythran
>
>
Author
27 Oct 2006 4:37 PM
Mythran
Show quote Hide quote
"Mythran" <kip_pot***@hotmail.com> wrote in message
news:ua34f0d#GHA.4196@TK2MSFTNGP03.phx.gbl...
>
>
> "Cas" <c**@qscq.op> wrote in message
> news:uqXdCvY#GHA.4980@TK2MSFTNGP04.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_pot***@hotmail.com> schreef in bericht
>> news:et6d6VV%23GHA.1200@TK2MSFTNGP02.phx.gbl...
>>>
>>>
>>> "Cas" <c**@qscq.op> wrote in message
>>> news:eqFf7wT#GHA.4708@TK2MSFTNGP05.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...instead, 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
Author
28 Oct 2006 1:55 AM
Göran_Andersson
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 HtmlGenericControl for that, just as for the
div tag.

Cas wrote:
Show quoteHide quote
> 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)
>
>
>
>
Author
28 Oct 2006 5:38 PM
Cas
Thanks

Show quoteHide quote
"Göran Andersson" <gu***@guffa.com> schreef in bericht
news:ukJs1Qj%23GHA.3352@TK2MSFTNGP03.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 HtmlGenericControl 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)
>>
>>
>>