Label not able to take <p>

T

tshad

I have an asp:Label that I am trying display some formatted text.

I can do this in my aspx page, but not from Javascript where I am getting
the text from the opener. I couldn't figure out why my script stopped
executing until I realized what was happening.

In my script I am doing this:

var toCoverLetterDisplay =
document.getElementById('_ctl0_ResumeDisplay_CoverLetterDisplay');

CoverLetterDisplay is an asp:Label which renders into a span element.

So

<asp:Label Text="<p>This is the CoverLetterDisplay</p>"
ID="CoverLetterDisplay" runat=server/>

Renders into

<span id="_ctl0_ResumeDisplay_CoverLetterDisplay"><p>This is the
CoverLetterDisplay</p></span>

In my asp code I can do:

CoverLetterDisplay.Text = "<p>This is the text from the
CoverLetterTextBox.</p>"

I can also do:

toCoverLetterDisplay.innerHTML = "This is a test"

But I can't do:

toCoverLetterDisplay.innerHTML = "<p>This is a test</p>;

or

var test = "<p>This is a test</p>";
toCoverLetterDisplay.innerHTML = test;

What is the problem?

I assume this has something to do with the chevrons.

The problem is that I am trying to move Formatted text from a textarea on my
opener page to an asp:Label on my new page. How do I do this in my
JavaScript function?

Thanks,

Tom
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

tshad said:
I have an asp:Label that I am trying display some formatted text.

I can do this in my aspx page, but not from Javascript where I am getting
the text from the opener. I couldn't figure out why my script stopped
executing until I realized what was happening.

In my script I am doing this:

var toCoverLetterDisplay =
document.getElementById('_ctl0_ResumeDisplay_CoverLetterDisplay');

CoverLetterDisplay is an asp:Label which renders into a span element.

So

<asp:Label Text="<p>This is the CoverLetterDisplay</p>"
ID="CoverLetterDisplay" runat=server/>

Renders into

<span id="_ctl0_ResumeDisplay_CoverLetterDisplay"><p>This is the
CoverLetterDisplay</p></span>

In my asp code I can do:

CoverLetterDisplay.Text = "<p>This is the text from the
CoverLetterTextBox.</p>"

I can also do:

toCoverLetterDisplay.innerHTML = "This is a test"

But I can't do:

toCoverLetterDisplay.innerHTML = "<p>This is a test</p>;

or

var test = "<p>This is a test</p>";
toCoverLetterDisplay.innerHTML = test;

What is the problem?

I assume this has something to do with the chevrons.

The problem is that I am trying to move Formatted text from a textarea on my
opener page to an asp:Label on my new page. How do I do this in my
JavaScript function?

Thanks,

Tom

The paragraph tag is a block tag while a span is an inline tag. You
can't place block tags inside inline tags.

Use a Panel instead of the Label.
 
T

tshad

Göran Andersson said:
The paragraph tag is a block tag while a span is an inline tag. You can't
place block tags inside inline tags.

Use a Panel instead of the Label.

That did it.

But why can I set the asp:Label fine but not the <span> if the asp:Label
renders into a <span> tag?

Thanks,

Tom
 
T

tshad

Also, a problem with using a Panel, is I can't set the text from asp.net - I
get an error saying there is no text attribute for panel.

If I have a <asp:panel ID="CoverLetter" runat="server"/>,

I cannot do:

CoverLetter.Text = "something or other"

But I can from JavaScript do:

var toCoverLetter =
document.getElementById('_ctl0_ResumeDisplay_CoverLetter');
toCoverLetter.innerHTML = "something or other".

Is there a way to set this from vb.net code?

Thanks,

Tom.
tshad said:
Göran Andersson said:
The paragraph tag is a block tag while a span is an inline tag. You can't
place block tags inside inline tags.

Use a Panel instead of the Label.

That did it.

But why can I set the asp:Label fine but not the <span> if the asp:Label
renders into a <span> tag?

Thanks,

Tom
 
G

Guest

Use a div tag with the runat=server attribute. It has the InnerHtml property.
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



tshad said:
Also, a problem with using a Panel, is I can't set the text from asp.net - I
get an error saying there is no text attribute for panel.

If I have a <asp:panel ID="CoverLetter" runat="server"/>,

I cannot do:

CoverLetter.Text = "something or other"

But I can from JavaScript do:

var toCoverLetter =
document.getElementById('_ctl0_ResumeDisplay_CoverLetter');
toCoverLetter.innerHTML = "something or other".

Is there a way to set this from vb.net code?

Thanks,

Tom.
 

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,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top