javascript references becoming undefined when adding validators

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlsZXM=?=, Aug 11, 2005.

  1. 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.
     
    =?Utf-8?B?TWlsZXM=?=, Aug 11, 2005
    #1
    1. Advertising

  2. 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.
     
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Aug 11, 2005
    #2
    1. Advertising

  3. RE: javascript references becoming undefined when adding validator

    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.
     
    =?Utf-8?B?TWlsZXM=?=, Aug 11, 2005
    #3
  4. RE: javascript references becoming undefined when adding validator

    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.
     
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Aug 11, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ratman
    Replies:
    0
    Views:
    715
    Ratman
    Sep 14, 2004
  2. xyZed
    Replies:
    9
    Views:
    647
    Big Bill
    May 12, 2004
  3. gong
    Replies:
    6
    Views:
    386
    gong li
    Aug 8, 2003
  4. DANIEL BEAULIEU J

    Becoming familiar with memory management

    DANIEL BEAULIEU J, Feb 9, 2005, in forum: C++
    Replies:
    2
    Views:
    319
    Andreas Wachowski
    Feb 13, 2005
  5. Curious Student

    Becoming a C _developer_

    Curious Student, May 31, 2004, in forum: C Programming
    Replies:
    7
    Views:
    323
    Sathyaish
    Jun 4, 2004
Loading...

Share This Page