Tim
Tim

Reputation: 43

How to set Textbox value at page load?

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

Upvotes: 4

Views: 20638

Answers (3)

Abe Miessler
Abe Miessler

Reputation: 85056

If it is an ASP.NET TextBox Try this:

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

Upvotes: 2

Amr Elgarhy
Amr Elgarhy

Reputation: 68912

You can use document.ready

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

Upvotes: 0

Amit
Amit

Reputation: 22076

Try this

<script type="text/javascript">
    $(document).ready(function() {
            $("#TextBox1").val("Hello World");
            });
</script>

Upvotes: 3

Related Questions