|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to put two textboxes under each other?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)
Show quote
Hide quote
"Cas" <c**@qscq.op> wrote in message Is this for a windows app or for a web app?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) > > > > Mythran 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 > >
Show quote
Hide quote
"Cas" <c**@qscq.op> wrote in message Personally, I would use absolute positioning...instead, while dynamically 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 >> >> > > 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 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 > > "André" <s**@sdv.sd> wrote in message How do you mean "more or less correctly..."? Do you want them displayed 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 .... > 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 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 > >
Show quote
Hide quote
"Mythran" <kip_pot***@hotmail.com> wrote in message That should read, "Personally, I would NOT use ..."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 > > :P MythranI 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) > > > > 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) >> >> >> |
|||||||||||||||||||||||