Pages

Men

rh

8/18/2014

How to get a value from controls using JQUERY in asp.net with C#

Get label value:
1$('#<%=Label1.ClientID%>').text();
Set label value:
1$('#<%=Label1.ClientID%>').text("New Value");
Get Textbox value:
1$('#<%=TextBox1.ClientID%>').val();
Set Textbox value:
1$('#<%=TextBox1.ClientID%>').val("New Value");
Get Dropdown value:
1$('#<%=DropDownList1.ClientID%>').val();
Set Dropdown value:
1$('#<%=DropDownList1.ClientID%>').val("New Value");
Get text of selected item in dropdown:
1$('#<%=DropDownList1.ClientID%> option:selected').text();
Get Checkbox Status:
1$('#<%=CheckBox1.ClientID%>').attr('checked');
Check the Checkbox:
1$('#<%=CheckBox1.ClientID%>').attr('checked',true);
Uncheck the Checkbox:
1$('#<%=CheckBox1.ClientID%>').attr('checked',false);
Get Radiobutton Status:
1$('#<%=RadioButton1.ClientID%>').attr('checked');
Check the RadioButton:
1$('#<%=RadioButton1.ClientID%>').attr('checked',true);
Uncheck the RadioButton:
1$('#<%=RadioButton1.ClientID%>').attr('checked',false);
Disable any control:
1$('#<%=TextBox1.ClientID%>').attr('disabled', true);
Enable any control:
1$('#<%=TextBox1.ClientID%>').attr('disabled', false);
Make textbox read only:
1$('#<%=TextBox1.ClientID%>').attr('readonly', 'readonly');

No comments :

Post a Comment