Thursday, October 24, 2013

Jquery to Get TextBox Value in Asp.net

Leave a Comment
With the help of the jquery code you can get the text being entered inside asp.net textbox control.
Jquery val() method is used for this purpose. Below is simple juery code in which on the click of the button I am displaying the text entered in the textbox. 

Jquery to Get Value of Asp.Net TextBox control:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $(function () {

                $('#btngettext').click(function (e)
                {
                    var GetValue = $('#txtname').val();
                    alert(GetValue);
                });
            });

        });


    </script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:TextBox runat="server" ID="txtname"></asp:TextBox>
            <asp:Button runat="server" ID="btngettext" Text="Display" />


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

0 comments:

Post a Comment