4

I have to set asp.net TextBox’s value at page load using JQuery.
Can somebody give me example ?

3 Answers 3

3

Try this

<script type="text/javascript">
    $(document).ready(function() {
            $("#TextBox1").val("Hello World");
            });
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

I have accepted his answer because he has given answer before any one else. All other answer is almost copy of his answer.
If you are using an HTML textbox this is the correct answer. If you were trying to do an ASP.NET textbox then this will not work.
For an ASP.NET TextBox that has the ID TextBox1? <asp:TextBox ID="TextBox1" ....
2

If it is an ASP.NET TextBox Try this:

<script type="text/javascript">
    $(document).ready(function(){
        $('#<%= tb_ASPTextBox.ClientID %>').val("my value"); 
    });
</script>

Comments

0

You can use document.ready

Example http://fiddle.jshell.net/UB5L9/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.