Useful jQuery code examples for ASP.NET Controls

Earlier I had posted about Using jQuery with ASP.NET and in this post, you will find list of some useful jQuery code example for ASP.NET controls that we use on daily basis. One thing, while creating object of any ASP.NET control, always use ClientID. As when Master pages are used then the ID of the ASP.NET controls is changed at run time. Read more here.

Get label value:
Set label value:
$('#<%=Label1.ClientID%>').text("New Value");
Get Textbox value:
Set Textbox value:
$('#<%=TextBox1.ClientID%>').val("New Value");
Get Dropdown value:
Set Dropdown value:
$('#<%=DropDownList1.ClientID%>').val("New Value");
Get text of selected item in dropdown:
$('#<%=DropDownList1.ClientID%> option:selected').text();
Get Checkbox Status:
Check the Checkbox:
Uncheck the Checkbox:
Get Radiobutton Status:
Check the RadioButton:
Uncheck the RadioButton:
Disable any control:
$('#<%=TextBox1.ClientID%>').attr('disabled', true);
Enable any control:
$('#<%=TextBox1.ClientID%>').attr('disabled', false);
Make textbox read only:
$('#<%=TextBox1.ClientID%>').attr('readonly', 'readonly');
Share your useful code as well (via commenting), I will add this into this list.
Feel free to contact me for any help related to jQuery, I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..