By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,276 Members | 1,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,276 IT Pros & Developers. It's quick & easy.

javascript references becoming undefined when adding validators

P: n/a
I have an ASP.Net text box which I am adding a javascript event (onChange) at
runtime. It passes a parameter which is another control which I am getting
the name for from the ClientID property.

So when rendered looks like:

<input name="txtVal" type="text" id="txtVal" onChange="DoCalc(txtVal2);"/>

This works fine, but as soon as I add a rangeValidator to the txtVal2
control and the event fires it fails with a txtVal2 is undefined error?
Removing the validator recifies the problem.

Any help would be appreciated.
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Not sure what could be this issue.. But have you tried
onChange="DoCalc(this);" ?

this will pass the reference of object making the function call...

"Miles" wrote:
I have an ASP.Net text box which I am adding a javascript event (onChange) at
runtime. It passes a parameter which is another control which I am getting
the name for from the ClientID property.

So when rendered looks like:

<input name="txtVal" type="text" id="txtVal" onChange="DoCalc(txtVal2);"/>

This works fine, but as soon as I add a rangeValidator to the txtVal2
control and the event fires it fails with a txtVal2 is undefined error?
Removing the validator recifies the problem.

Any help would be appreciated.

Nov 19 '05 #2

P: n/a
Unfortunatley it needs to pass a different control to a function in a
javascript file file so even if this worked i wouldnt allow the desired
functionality.

"Sreejith Ram" wrote:

Not sure what could be this issue.. But have you tried
onChange="DoCalc(this);" ?

this will pass the reference of object making the function call...

"Miles" wrote:
I have an ASP.Net text box which I am adding a javascript event (onChange) at
runtime. It passes a parameter which is another control which I am getting
the name for from the ClientID property.

So when rendered looks like:

<input name="txtVal" type="text" id="txtVal" onChange="DoCalc(txtVal2);"/>

This works fine, but as soon as I add a rangeValidator to the txtVal2
control and the event fires it fails with a txtVal2 is undefined error?
Removing the validator recifies the problem.

Any help would be appreciated.

Nov 19 '05 #3

P: n/a
my mistake! .. didnt notice the control being passed is different..

"Miles" wrote:
Unfortunatley it needs to pass a different control to a function in a
javascript file file so even if this worked i wouldnt allow the desired
functionality.

"Sreejith Ram" wrote:

Not sure what could be this issue.. But have you tried
onChange="DoCalc(this);" ?

this will pass the reference of object making the function call...

"Miles" wrote:
I have an ASP.Net text box which I am adding a javascript event (onChange) at
runtime. It passes a parameter which is another control which I am getting
the name for from the ClientID property.

So when rendered looks like:

<input name="txtVal" type="text" id="txtVal" onChange="DoCalc(txtVal2);"/>

This works fine, but as soon as I add a rangeValidator to the txtVal2
control and the event fires it fails with a txtVal2 is undefined error?
Removing the validator recifies the problem.

Any help would be appreciated.

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.