Now, we understood the concept of JQuery and How to use JQuery in ASP.Net.
In this ASP.Net Jquery Post we will learn to Assign value to TextBox control in ASP.Net.
First, Download JQuery library from http://jquery.com/. and include in web page at head section.
Design the ASP.Net web form with one Button and one TextBox control.
First, clear the TextBox control text value, when we click button then assign value to TextBox control.
write below code for design asp.net web form:
<asp:TextBox ID=”TextBox1″ runat=”server” Height=”24px” Width=”140px”></asp:TextBox>
<asp:Button ID=”Button2″ runat=”server” Text=”Assign Value” />
The out put of design asp.net web form :
Now, Write below JQuery code for assign value to Textbox control.
<head runat=”server”>
<title>JQuery in ASP.Net</title>
<script src=”jquery-1.4.3.min.js” type=”text/javascript”></script>
<script>
$(document).ready(function() {
$(“#Button1”).click(function() {
$(‘#<%=TextBox1.ClientID%>’).val(“Meera Academy”);
});
});
</script>
</head>
The Result of JQuery Example is :
Now , we learn to get value from Textbox using JQuery.
Get value from TextBox syntax :
$(‘#<%=TextBox1.ClientID%>’).val();
I hope this JQuery Textbox Example will help you….