473,778 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with ASP.Net object and Javascript

I have a function:

function SalaryDisplay(m e)
{
var salaryMinLabel = document.getEle mentById("Salar yMin");
salaryMinLabel. value = 200;
alert("after setting salaryMinLabel = " + salaryMinLabel. value);
}

I also have an 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.

Is there a problem setting the span element?

Thanks,

Tom
Jul 23 '05
54 4612
"RobG" <rg***@iinet.ne t.auau> wrote in message
news:42******** *************** @per-qv1-newsreader-01.iinet.net.au ...
tshad wrote:
These look pretty good.

I need to spend some time to digest them.

What does "/input/i.test(f[i].nodeName" and "/text/i.test(f[i].type"
mean?


/input/i creates a regular expression (RegExp) out of 'input' and the
i flag makes it case insensitive. 'test' will compare it to the
element f[i] nodeName to see if it's an input.

It is effectively the same as:

if (f[i].nodeName.toLow erCase() == 'input')


Not to pick a nit, but nit-picking is what we do here:

if (/input/i.test(f[i].nodeName))

is closer to: if (f[i].nodeName.toLow erCase().indexO f('input') != -1)

than it is to: if (f[i].nodeName.toLow erCase() == 'input')

The reason I prefer the regex is because f[i].nodeName may not be typeof
'string', and if it isn't, f[i].nodeName.toLow erCase() will fail. Of
course this could be avoided with:

if ('string' == typeof f[i].nodeName &&
f[i].nodeName.toLow erCase().indexO f('input') != -1)

but:

if (/input/i.test(f[i].nodeName))

is easier to read, probably faster (although speed isn't the primary
consideration in choosing this mechanism) and guaranteed to produce the
correct result regardless of the typeof f[i].nodeName.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #21
David Dorward wrote:
Span elements don't have values. You need to create a new text node then
append it to the element to add text to it. Look at the JavaScript section
of the DOM 1 specification. http://w3.org/DOM/


There is no JavaScript section (only an `ECMAScript binding' section),
and since W3C DOM Level 1 HTML has been obsoleted by W3C DOM Level 2 HTML
which builds on W3C DOM Level 2 Core, one should look at the latter
instead. The respective sections are:

<http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247>
<http://www.w3.org/TR/DOM-Level-2-Core/ecma-script-binding.html>
PointedEars
Jul 23 '05 #22
tshad wrote:
<script language="javas cript1.4">


This is not Valid HTML and error-prone. Use

<script type="text/javascript">

instead.
PointedEars
--
There are two possibilities: Either we are alone in the
universe or we are not. Both are equally terrifying.
-- Arthur C. Clarke
Jul 23 '05 #23
Grant Wagner wrote:
RobG wrote: <snip>
if (f[i].nodeName.toLow erCase() == 'input')

<snip> The reason I prefer the regex is because f[i].nodeName may
not be typeof 'string', and if it isn't,
f[i].nodeName.toLow erCase() will fail. Of course this could
be avoided with:

if ('string' == typeof f[i].nodeName &&
f[i].nodeName.toLow erCase().indexO f('input') != -1)

but:

if (/input/i.test(f[i].nodeName))

is easier to read, probably faster (although speed isn't
the primary consideration in choosing this mechanism) and
guaranteed to produce the correct result regardless of the
typeof f[i].nodeName.


An alternative to safe execution with the comparison operation could
be:-

if((new String(f[i].nodeName)).toL owerCase() == 'input')

- and/or:-

if( (new String(f[i].nodeName)).toL owerCase().inde xOf('input') != -1 )

- because the result of applying the ECMAScript internal ToString
function to null or undefined are known strings that do not resemble
'input'. The safety measure also has the advantage of not carrying an
overhead as the construction of the String object was implied by the
context of a String method call (assuming f[i].nodeName actually was a
string to start with).

Richard.
Jul 23 '05 #24
Thomas 'PointedEars' Lahn wrote:

There is no JavaScript section (only an `ECMAScript binding' section),
synonyms :)
and since W3C DOM Level 1 HTML has been obsoleted by W3C DOM Level 2 HTML
which builds on W3C DOM Level 2 Core, one should look at the latter
instead.


The DOM 2 spec says that it builds on the DOM 1 spec, so wouldn't it
supplement it rather then obsolete it?

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #25
"Richard Cornford" <Ri*****@litote s.demon.co.uk> writes:
An alternative to safe execution with the comparison operation could
be:-

if((new String(f[i].nodeName)).toL owerCase() == 'input')


While it's probably not hurtfull in any way, you never need to create
a new String object explicitly. Exactly the same effect would be
achieved by
if ((String(f[i].nodeName)).toL owerCase() == 'input')

Behind the scenes, there might be created a new String object anyway,
in order to call it's toLowerCase method, but an intelligent
Javascript interpreter should be able to optimize that away (should
such one exist).
I just don't like to see "new String(...)" :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #26
Lasse Reichstein Nielsen wrote:
Richard Cornford wrote:
An alternative to safe execution with the comparison
operation could be:-

if((new String(f[i].nodeName)).toL owerCase() == 'input')
While it's probably not hurtfull in any way, you never need
to create a new String object explicitly. Exactly the same
effect would be achieved by
if ((String(f[i].nodeName)).toL owerCase() == 'input')


Yes, the end result would be identical.
Behind the scenes, there might be created a new String
object anyway, in order to call it's toLowerCase method,
That is what ECMA 262 says happens when a method of a string object is
called on a string primitive.
but an intelligent Javascript interpreter
should be able to optimize that away (should
such one exist).
Yes, implementations may optimise any aspects of ECMA 262, they are only
required to behave (or appear to behave) as if they were following the
specification. But it is extremely difficult to tell which are
optimising what, and how. And in the cross-browser scripting world we
should not be too interested in optimisations that may only apply to
some implementations .
I just don't like to see "new String(...)" :)


And I don't mind seeing it when it is serving some purpose. Certainly
whenever I am planning to call more than three or so String methods on a
single string primitive I will usually explicitly convert it into a
String object (so that it is not necessary for the interpreter to do so
internally for each method call).

As a method of rendering a questionable, but probably string type,
property safe for the application of String methods I wouldn't argue
that passing the property's value through the String constructor called
as a function is equally effective. But as the language specification
says that an intermediate String object is created I see the explicit
construction of a String object as no more than rendering apparent what
should be expected to be happening anyway. (By 'expected' I mean that an
understanding based on the spec should expect that to be happening
conceptually, not that the interpreter actually has to be doing it.)

Maybe it is just a matter of personal bias, with my predominantly OO
programming experience numbing me to the sight of just another object
being constructed and your (I would guess) greater experience of
functional programming (certainly greater than mine) leaving you
preferring to see functions used. Or is there something more tangible
that can be said against the use of the object constructor?

You have probably guessed that I am not buying the efficiency due to
possible optimisation argument. And would counter by pointing out that
by the spec the implied String object creation will mean one extra call
to the internal ToString method with your version. Though as that call
is passing ToString a string primitive argument, which will just be
returned unaltered, the difference would be expected to be negligible.

Richard.
Jul 23 '05 #27
David Dorward wrote:
Thomas 'PointedEars' Lahn wrote:
There is no JavaScript section (only an `ECMAScript binding' section),


synonyms :)


Joky: yes :) Seriously: no.
and since W3C DOM Level 1 HTML has been obsoleted by W3C DOM Level 2 HTML
which builds on W3C DOM Level 2 Core, one should look at the latter
instead.


The DOM 2 spec says that it builds on the DOM 1 spec, so wouldn't it
supplement it rather then obsolete it?


Yo (Yes and no ;-)). See for yourself:

,-<http://www.w3.org/TR/DOM-Level-2-HTML/>
|
| Note: This specification renders the DOM Level 1 HTML Recommendation
| obsolete given that some changes from DOM Level 1 HTML are incompatible
| with that specification but represent more accurately the state of
| deployed software. W3C strongly suggests that developers and authors
| conform to DOM Level 2 HTML instead.
PointedEars
--
Viele glauben bloß, daß neue Formulierungen
altem Unsinn neuen Sinn einhauchen könnten.
-- Jürgen 'Jygn' Klingforth in dag°
<ar************ **@klingforth.d e>
Jul 23 '05 #28
Thomas 'PointedEars' Lahn wrote:
synonyms :)
Joky: yes :) Seriously: no.
Then what is the difference? I was under the impression that ECMAScript was
just the standard that was created from JavaScript and that browsers
implemented the standard now.
The DOM 2 spec says that it builds on the DOM 1 spec, so wouldn't it
supplement it rather then obsolete it?

,-<http://www.w3.org/TR/DOM-Level-2-HTML/>


Ah, I was looking at the DOM 2 Core which didn't mention that.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #29
David Dorward schrieb:
Thomas 'PointedEars' Lahn wrote:
synonyms :)
Joky: yes :) Seriously: no.


Then what is the difference? I was under the impression that
ECMAScript was just the standard that was created from JavaScript


(I had almost posted a lengthy detailed explanation but for some reason
it did not make it into the newsgroup. So now I write only this:)

Correct. You could call ECMAScript a subset of JavaScript since
not all JavaScript 1.1+ features made it into ECMAScript, e.g.
Getters and Setters.
and that browsers implemented the standard now.


They implement Netscape JavaScript or Microsoft JScript which extend
standardized ECMAScript. They also implement and extend the W3C DOM,
a quasi-standard; the UA's DOM can also be accessed with ECMAScript
implementations (JavaScript in Gecko-based UAs, JScript in IE-based
ones) through the respective language binding feature.

I, among others, have already posted related information or pointers
thereto here several times. Google is your friend. [psf 6.1]
HTH

PointedEars
Jul 23 '05 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6090
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory loss even though I seem to be allocaitng everything; help would be *vastly* appreciated. What am I doing wrong here? I thought I was doing everything correctly (setting things to null, for example) but none of the memory seems to get replaced. ...
5
1549
by: Shawn Modersohn | last post by:
For the script: <script language="JavaScript"> function pullPage(){ var arrayLength=document.teamSelectionF.teamSelectionS.length; var pageNav = new Array(arrayLength); var gotoNum=document.teamSelectionF.teamSelectionS.options.value; pageNav="http://www.tandtsports.com"; pageNav="http://www.tandtsports.com/Cougars.html";
55
4215
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems with this sort of thing? I know some of these potential users are with big companies and am wondering if anyone had real problems with that.
10
19176
by: Danny | last post by:
Hi all, I am having some odd problems with AJAX on Firefox (1.5). When I use GET as the request method everything works ok, but when I do a POST the remote function doesn't get the parameters I am passing to it. Everything works fine on IE 6. Here's a couple samples of what I am doing: // using GET url = 'http://www.myserver.com/cgi-bin/funct?key1=value1&key2=value2'
2
2099
by: beseecher | last post by:
Hi, In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: function A(){ var _this = this; this.a = 10;
1
4954
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: http://munich.schwarz-interactive.de/autocomplete.aspx
1
3426
by: kevin.a.sweeney | last post by:
I would like to open an application from a hyperlink on a webpage. 1. the webpage is located on my local machine. 2. the application is located on my local machine. 3. the application will run on my local machine. In other words... The WEB is really not involved. What I have so far works with a Netscape Browser but what I really need is for it to work in the IE browser or one that I will create
14
2818
by: julie.siebel | last post by:
I've been wrestling with a really complex page. All the data is drawn down via SQL, the page is built via VBScript, and then controlled through javascript. It's a page for a travel company that shows all the properties, weeks available, pricing, etc. for a particular area of Europe. The data varies widely depending on the region; at times there will be 50 properties, and at other times only a half dozen. The cross referencing of...
1
1866
RMWChaos
by: RMWChaos | last post by:
I grabbed this "Rock Solid addEvent" code from this site, which is based on Mark Wubben's event-cache code. (These links for reference only.) I am having two problems with it, and the webmaster is s...l...o...w to respond. So I thought I would ask about it here. If I knew more about how this code works, I could probably figure out most of the problems myself, but with this one, I am clueless! =D First question: This may be my own...
10
1854
by: jodleren | last post by:
Hi I know, that there are a lot of people having problems with orkut.com, errors like "object expected" and named objects missing. When loading the site can generate some 10 errors, and still just leave a blue page - seems like it heavily rely on JS. Still, me and friends having problems and orkut seems just to ignore it. I am sure, that other poeple have problems, and I really wonder what
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.