Tuesday 15 May 2012

Get textbox value in javascript

Add textbox to a WebPage


<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox10" runat="server" Width="200" Height="50" Text="Static Text Box" Font-Size="X-Large" ForeColor="#CC3300" BackColor="Yellow"></asp:TextBox>

<asp:Button ID="Button1" runat="server"  OnClientClick ='TextBoxValue()' text='get textbox value' />

<script type='text/javascript'>
    function TextBoxValue() {
        var textbox = document.getElementById("TextBox10");
        alert(textbox.value);
    }
</script>


    </div>
    </form>
</body>




note: cut & paste in ur aspx source

following output it will generate


No comments:

Post a Comment