Using jQuery Code to Work with ASP.Net Controls
jQuery is Open Source JavaScript Library. It contains easy to use methods and functions to make rich web applications. In this Article I am providing jQuery syntaxes to work with some standard ASP.Net Controls
jQuery is Open Source JavaScript Library. It contains easy to use methods and functions to make rich web applications. jQuery is used in Visual Studio to implement several Client Side functionalities in the ASP.Net Web Page.
Steps to used jQuery in the ASP.Net Page.
1. Add the jQuery Library to the ASP.Net Project in the Solution Explorer.
2. Place the jQuery Library in the ASP.Net [.aspx] page in side the script tag.Get/Set Value from ASP.Net Textbox Control using jQuery
1. To Get the Value from the Textbox
var uName = $("#txtUName").val()
2. To Set the Value to the Text
$('#txtM').val("Hello");
To Check the Status of the Checkbox
if ($("#chkPassport").is(':checked')) {
alert("Yes I have a Passport");
}
if($('#chkPassport').attr('checked')) {
alert("Yes I have a Passport");
}Working with DropdownList
// Retrieves the Text of the Selected Item
var itemText = $("#ddlCity option:selected").text();
// Retrieves the value of the selected item
var itemValue = $("#ddlCity option:selected").val();
// Returns the Index Value of the selected item in the Dropdown
var ItemIndex = $("#ddlCity").get(0).selectedIndex;