469,358 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

concat a space on an HTML controls innerText property

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
Nov 19 '05 #1
10 2603
try celCreate.innerText = "  TEST"

Nov 19 '05 #2
"=?Utf-8?B?QW5nZWw=?=" <An***@discussions.microsoft.com> wrote in
news:C5**********************************@microsof t.com:
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", " ", "&nbsp;")

Use &nbsp; for spaces.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #3


--
-Demetri
"Angel" wrote:
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

Nov 19 '05 #4
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" (&nbsp;) character for each blank space you want.

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

crazy but true.

-HTH

"Angel" <An***@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
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

Nov 19 '05 #5


Angel wrote:
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  .

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 19 '05 #6
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

"Jordan" wrote:
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

"Angel" <An***@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
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


Nov 19 '05 #7
Sorry I meant:

aCell.innerText = " TEST"

"Angel" wrote:
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

"Jordan" wrote:
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

"Angel" <An***@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
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


Nov 19 '05 #8
It will recognize and display one blank space - which is what you have. If
you want more, then you need &nbsp;


"Angel" <An***@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Sorry I meant:

aCell.innerText = " TEST"

"Angel" wrote:
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

"Jordan" wrote:
> 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
>
>
>
> "Angel" <An***@discussions.microsoft.com> wrote in message
> news:C5**********************************@microsof t.com...
> >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
>
>
>

Nov 19 '05 #9
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.

"Jordan" wrote:
It will recognize and display one blank space - which is what you have. If
you want more, then you need


"Angel" <An***@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Sorry I meant:

aCell.innerText = " TEST"

"Angel" wrote:
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

"Jordan" wrote:

> 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
>
>
>
> "Angel" <An***@discussions.microsoft.com> wrote in message
> news:C5**********************************@microsof t.com...
> >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
>
>
>


Nov 19 '05 #10
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)?

"Angel" <An***@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
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.

"Jordan" wrote:
It will recognize and display one blank space - which is what you have.
If
you want more, then you need


"Angel" <An***@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
> Sorry I meant:
>
> aCell.innerText = " TEST"
>
> "Angel" wrote:
>
>> 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
>>
>> "Jordan" wrote:
>>
>> > 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
>> >
>> >
>> >
>> > "Angel" <An***@discussions.microsoft.com> wrote in message
>> > news:C5**********************************@microsof t.com...
>> > >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
>> >
>> >
>> >


Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by MB | last post: by
4 posts views Thread by keerthana_m_2003 | last post: by
7 posts views Thread by David Thielen | last post: by
3 posts views Thread by Jon Davis | last post: by
2 posts views Thread by ViperDK | last post: by
17 posts views Thread by Lloyd Sheen | last post: by
6 posts views Thread by martin | last post: by
6 posts views Thread by Lloyd Sheen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.