Adding Blanks Lines Inside a Webform

  • Thread starter Thread starter CapRand
  • Start date Start date
C

CapRand

Hi,

I am creating an ASP.NET site and have created a form which I have
been able to dynamically with listboxes, labels etc from a database -
using mainly form1.Controls.Add .....

Does anyone know how I can add blank lines to a form. If I use
response.write it writes to the body of the HTML and not inside the
form. I am sure it must be easy but it has got me stuck. I have tried
adding a label with vbcrlf inside it but the CRLF stays inside the
label and doesn't force a new line on the client side page.

I would like to be able to newlines from the code behind aspx.vb as
the number of them may change each time depending on other bits of
logic in the code.

Any help would be very much appreciated!

Thanks

Pete
 
It sounds to me like you just need to add a <br/> in your code. The best way
to do this when creating the page dynamically by use of the Add() method is
to create the following:

<asp:Literal runat="server" Mode="PassThrough" Text="<br/>"/>

You must use the Mode="PassThrough" or else ASP.NET will convert it to
&lt;br/&gt; (or something like that). The code to create the control would
be:

Dim brtag As New Literal()
brtag.Mode = LiteralMode.PassThrough
brtag.Text = "<br/>"

And then add it using the Add(brtag) just like you would add any other
control. In your code, this will show up as nothing more than "<br/>" (it
will not have an extra id attribute or anything else that is added to most
tags). When I write an application in which I have to dynamically add <br/>
tags, I write an extra subroutine, since you will probably be adding
multiple <br/> tags when you create an entire page dynamically. Hopefully
this helps.
 
Back
Top