Home > Code > Jquery > Get textbox value using jquery in asp.net

Get textbox value using jquery in asp.net

by Raja   on May 30, 2011   Category: Jquery   |  Views: 8481    |  Points: 25   |  Bronze 


Code snippet for get the textbox value using jquery in the asp.net application. Include the necessary jquery file in the application and use the below code.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Jquery test</title>
<script src="/javascript/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#<%= btnGetValue.ClientID %>").click(function() {
alert($("#<%= txtname.ClientID %>").val());
return true;
});
});
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
Enter Name : <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<asp:Button ID="btnGetValue" runat="server" Text="Get Value" />
</div>
</form>
</body>
</html>





Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts