Trying to get javascript to insert a string into a textbox or label in asp.net is this possible? (error: document.getElementById(..) is null or not an object)

adypips
adypips used Ask the Experts™
on
Hi I am trying to get the below javascript code to insert into a textbox. Note this is stored in an asp.net page.
 I would like to try and store in an asp.net label if possible or a asp.net textbox (if this is not possible a normal html textbox would do).

     
        <input id="Text1" type="text" />

This is not working I am currently getting the following error message: document.getElementById(..) is null or not an object

<script type="text/javascript">
    
document.getElementById("Text1").value= "Will this store";
 
</script>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
solved..  see link http://www.programmersheaven.com/mb/java-script/324468/324468/null-or-not-an-object/?S=B20000 

Depends on position of javascript in head or below the textbox or lablel (if you put above -to javascript it renders top to bottom i.e that element doesnt exist if above).

Commented:
did your <input id="Text1" type="text" /> has runat="server" attribute ?

what is id of this Text1 in View source of browser.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial