Newbie questio, null or not an object

Discussion in 'ASP .Net' started by Henke, Nov 26, 2003.

  1. Henke

    Henke Guest

    To an WebForm I add a HTML button and a HTML TextBox, txt1.
    On the onclick event of the button I call a function called test, The
    function looks like this:
    <script>
    function test()
    {
    txt1.value = "test";
    }
    </scipt>

    When i run the application I get an error message:
    "txt1 is null or not an object"

    Why does this happens?
    Thanks!
     
    Henke, Nov 26, 2003
    #1
    1. Advertising

  2. Henke

    Kairi Zikpin Guest

    i think you need to fully qualify txt1
    ie
    formname.txt1

    Henke wrote:
    > To an WebForm I add a HTML button and a HTML TextBox, txt1.
    > On the onclick event of the button I call a function called test, The
    > function looks like this:
    > <script>
    > function test()
    > {
    > txt1.value = "test";
    > }
    > </scipt>
    >
    > When i run the application I get an error message:
    > "txt1 is null or not an object"
    >
    > Why does this happens?
    > Thanks!
    >
    >
     
    Kairi Zikpin, Nov 27, 2003
    #2
    1. Advertising

  3. Henke

    Henke Guest

    Exactly, now it works on a form, thanks!

    Do you know how to do it when working with web user controls. If I have a
    button, a text box and my test() function on a user control I get the same
    problem. If I add the user control to a form called myForm and in the
    test-function write myForm.txt1.value = "test" then it works, but I'd like
    to be able to put my user controls on other forms then the ones called
    myForm...

    Thanks!


    "Kairi Zikpin" <> skrev i meddelandet
    news:7wcxb.504366$9l5.297716@pd7tw2no...
    > i think you need to fully qualify txt1
    > ie
    > formname.txt1
    >
    > Henke wrote:
    > > To an WebForm I add a HTML button and a HTML TextBox, txt1.
    > > On the onclick event of the button I call a function called test, The
    > > function looks like this:
    > > <script>
    > > function test()
    > > {
    > > txt1.value = "test";
    > > }
    > > </scipt>
    > >
    > > When i run the application I get an error message:
    > > "txt1 is null or not an object"
    > >
    > > Why does this happens?
    > > Thanks!
    > >
    > >

    >
     
    Henke, Nov 27, 2003
    #3
    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. AC

    JDBC Questio

    AC, Jan 31, 2005, in forum: Java
    Replies:
    2
    Views:
    417
  2. Replies:
    5
    Views:
    26,706
    Mike Schilling
    Mar 29, 2006
  3. Cirene
    Replies:
    1
    Views:
    817
    Alexey Smirnov
    Jun 9, 2008
  4. Catherine Heathcote

    Embarrasing questio

    Catherine Heathcote, Feb 12, 2009, in forum: Python
    Replies:
    13
    Views:
    377
    marika
    Feb 14, 2009
  5. putty
    Replies:
    1
    Views:
    260
    putty
    Apr 5, 2005
Loading...

Share This Page