Re: Label not able to take <p>

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Göran Andersson" <guffa@xxxxxxxxx> wrote in message
news:%239DwCIO8HHA.4476@xxxxxxxxxxxxxxxxxxxxxxx
tshad wrote:
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.

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öran Andersson
_____
http://www.guffa.com


.



Relevant Pages

  • Re: Adding rows to a table, works in Firefox, but not IE
    ... mark-up and they will be implied, the opening tag by any TR ... It sounds like the sort of thing that might come form someone familiarwith Java who has not understood that javascript is not Java. ... What is an inner function declaration? ... your assignment to it is an assignment to a property of the ...
    (comp.lang.javascript)
  • Re: RFD: How To Recognize Bad Javascript Code
    ... Elements consist of tags ... Your example `script' elements are empty where they should have ... | Using the pseudo-protocol javascript in the href is never valid. ... Some web developers use this to work ...
    (comp.lang.javascript)
  • Re: check email address is real
    ... MVP FrontPage ... it doesn't understand the tag it ignores it and reads whatever's inside. ... I just wouldn't put money on the noscript tag distinguishing between users ... The idea is, spambots do NOT execute javascript, and therefore ...
    (microsoft.public.frontpage.programming)
  • Getting the coordinates of a piece of text with Javascript?
    ... I know you can find the coordinates of a tag inside the DOM, ... If the user highlights or selects text in a div or span can I get the ... javascript do I use to find that out? ...
    (comp.lang.javascript)
  • Re: CSS positioning pickle
    ... from a vertical tag. ... I have a piece of javascript that grabs the ... this <span> only displays on mouseover. ...
    (comp.infosystems.www.authoring.html)