concat a space on an HTML controls innerText property

G

Guest

I want to concat a space in an HTML Control's innerText property. here is a
sample code

Dim celCreate As New HtmlControls.HtmlTableCell()

celCreate.innerText = " TEST"


When the page is displayed the spaces are not there! What can I do?

Thanks in advance
 
L

Lucas Tam

I want to concat a space in an HTML Control's innerText property. here
is a sample code

Dim celCreate As New HtmlControls.HtmlTableCell()

celCreate.innerText = " TEST"


When the page is displayed the spaces are not there! What can I do?

HTML doesn't allow for multiple spaces.

Instead... Replace(" TEST", " ", " ")

Use   for spaces.
 
J

Jordan

Browsers ignore white space (blank spaces beyond the first/only one if one
exists)

When you want more than one blank space, the solution is to explicitly place
a "nonbreaking space" ( ) character for each blank space you want.

So, your code with three blank spaces would be this:
celCreate.innerText = "   TEST"

crazy but true.

-HTH
 
M

Martin Honnen

Angel said:
I want to concat a space in an HTML Control's innerText property. here is a
sample code

Dim celCreate As New HtmlControls.HtmlTableCell()

celCreate.innerText = " TEST"


When the page is displayed the spaces are not there! What can I do?

Understand that normal HTML rendering collapses several white space
characters to one inter-word space:
<http://www.w3.org/TR/html4/struct/text.html#h-9.1>
If you want to have significant white space then use a <pre> element e.g.
<pre> TEST</pre>
or use a character like a non breaking space  .
 
G

Guest

Thanks for the responses. I tried this but when the asp.net page is displayed
it translates

aCell.innerText = " TEST"

it displays it literally like you see it.

" TEST"

If I look at the source of the page it translated the Code as such:

<tr>&nbsp;&nbsp;TEST</tr>

Any thoughts???

Thanks
 
G

Guest

Sorry I meant:

aCell.innerText = " TEST"

Angel said:
Thanks for the responses. I tried this but when the asp.net page is displayed
it translates

aCell.innerText = " TEST"

it displays it literally like you see it.

" TEST"

If I look at the source of the page it translated the Code as such:

<tr> TEST</tr>

Any thoughts???

Thanks
 
J

Jordan

It will recognize and display one blank space - which is what you have. If
you want more, then you need &nbsp;
 
G

Guest

You know what jordan I am writing my code as yyou specified and this message
that I am writing eliminated the HTML equvalent to the empty space. I do put
in my code as follows

aCell.innerText = Test

But what happens is that when the project runs the page gets translated and
the HTML that is outputed converts the ampersand up top to &nbsp;&nbsp;TEST.

any thoughts.

thanks.
 
J

Jordan

IF you are saying this:
"the HTML source shows &nbsp;"
as in this
<tr>&nbsp;&nbsp;TEST</tr>
which you posted earlier.

Then I'll say, "of course" Tha't the raw HTML you'll see IF/WHEN you view
the source from the browser.

You need to be clear on exactly what you're doing.
When you say "when the project runs the page gets translated " I have no
idea what you mean by "the page gets translated". That could mean many
different things. Do you mean "rendered in the browser" or are you viewing
the source *after* the browser has rendered it?

Are you saying that you see &nbsp; in the RENDERED page in the browser - or
are you seeing it in the page source when you go to View Source (of the
rendered page)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top