Re: Problems with ASP.Net object and Javascript
- From: "tshad" <tscheiderich@xxxxxxxxxxxxxxx>
- Date: Wed, 20 Apr 2005 17:53:44 -0700
"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
>> >
>>
>>
>>
.
- Follow-Ups:
- Re: Problems with ASP.Net object and Javascript
- From: gerrod
- Re: Problems with ASP.Net object and Javascript
- References:
- Problems with ASP.Net object and Javascript
- From: tshad
- Re: Problems with ASP.Net object and Javascript
- From: Marina
- Re: Problems with ASP.Net object and Javascript
- From: gerrod
- Problems with ASP.Net object and Javascript
- Prev by Date: How to display N records from a database in some Div's? Thanks.
- Next by Date: Re: Finding Hyperlinkcolumn
- Previous by thread: Re: Problems with ASP.Net object and Javascript
- Next by thread: Re: Problems with ASP.Net object and Javascript
- Index(es):
Relevant Pages
|