Re: Problems with ASP.Net object and Javascript

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



"gerrod" <gerrod@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A61B31D9-795E-4BF0-90C1-3A7AB7B96D0A@xxxxxxxxxxxxxxxx
> Stick with innerHTML as it's in the W3C standard.

How do you set this in Javascript and does it carry over to the asp.net
page?

Does that mean I don't need to add a node as I have been doing?

Thanks,

Tom

>
> innerText is only support by Internet Explorer.
>
> "Marina" wrote:
>
>> First off, anything you change in javascript isn't going to be visible in
>> View Source. That just shows the page exactly as it came down from the
>> server.
>>
>> Try setting the innerText or innerHTML properties of the span. The
>> 'value'
>> property is good for input controls, i don't think it works for spans.
>>
>> "tshad" <tscheiderich@xxxxxxxxxxxxxxx> wrote in message
>> news:ehVFpydRFHA.2932@xxxxxxxxxxxxxxxxxxxxxxx
>> >I am trying to set some labels to display calculated values with posting
>> >back to the server. So I am using Javascript to set the values of my
>> >asp:label. The problem is that an asp:lavel renders into a span
>> >element.
>> >
>> > For example:
>> >
>> > function SalaryDisplay(me)
>> > {
>> > var salaryMinLabel = document.getElementById("SalaryMin");
>> > salaryMinLabel.value = 200;
>> > alert("after setting salaryMinLabel = " + salaryMinLabel.value);
>> > }
>> >
>> > The asp.net object:
>> >
>> > <asp:label id="SalaryMin" runat="server" />
>> >
>> > Which renders into:
>> >
>> > <span id="SalaryMin"></span>
>> >
>> > The function seems to find the span fine. The alert box shows that it
>> > is
>> > set to 200. But the web page never shows it.
>> >
>> > There seemed to be a problem with the span element.
>> >
>> > Then I found out that the 'value' property on span does not display.
>> > The
>> > newly-created span element
>> > is empty and needs to have a text node appended. So to create the node
>> > I
>> > do the following:
>> >
>> > var salaryMinLabel = document.getElementById("SalaryMin");
>> > var sMLText = document.createTextNode("200")
>> > salaryMinLabel.appendChild(sMLText);
>> > alert("after setting salaryMinLabel = " +
>> > salaryMinLabel.firstChild.nodeValue);
>> >
>> > Even though it displays on the page the viewsource displays:
>> >
>> > Yearly Compens:<span id="SalaryMin"></span> /
>> > <span id="SalaryMax"></span>
>> >
>> > The value is not there.
>> >
>> > This obviously is not going to work. I spent a lot of time getting
>> > this
>> > work correctly and just found that if you go back a page (or forward)
>> > and
>> > then go back to the page - all this SPAN information that was just
>> > generated
>> > is now gone. Probably related to why it doesn't appear in Viewsource
>> > even
>> > though it is displaying on the original page.
>> >
>> > Is there a way to make sure it stays with the page on repost?
>> >
>> > Thanks,
>> >
>> > Tom
>> >
>>
>>
>>


.



Relevant Pages

  • Re: Problems with ASP.Net object and Javascript
    ... Stick with innerHTML as it's in the W3C standard. ... > Try setting the innerText or innerHTML properties of the span. ... So I am using Javascript to set the values of my ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Problems with ASP.Net object and Javascript
    ... Try setting the innerText or innerHTML properties of the span. ... So I am using Javascript to set the values of my ... The problem is that an asp:lavel renders into a span element. ... > Then I found out that the 'value' property on span does not display. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Display URL of Frame 2 in Frame 1
    ... display the URL of Frame2 in Frame1, ... I heard something with innerhtml may work too ... Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ ...
    (comp.lang.javascript)
  • Re: Empty + onlick
    ... Span 3 will not display the hand. ... Inline element, no content: ... Prototype.js was written by people who don't know javascript for people ...
    (comp.lang.javascript)
  • Re: Nested SPANs
    ... Replacing the message was the reason for the outer <SPAN> - just to contain some innerHTML that I could change with javaScript. ... I realised that I could have managed this all with one span, but since I was changing the innerHTML anyway, I realised that I could get away with two simple s, and some simple JavaScript. ...
    (comp.infosystems.www.authoring.html)