Assuming a ASP.NET button with ID "btnSubmit " is placed on the page.
And now bind the click event to ASP.NET Button in document.ready section.
Get label value:
Set label value:
Get Textbox value:
Set Textbox value:
Get Dropdown value:
Set Dropdown value:
Get text of selected item in dropdown:
Get Checkbox Status:
Check the Checkbox:
Uncheck the Checkbox:
Get Radiobutton Status:
Check the RadioButton:
Uncheck the RadioButton:
Disable any control:
Enable any control:
Make textbox read only:
1 | <asp:Button ID= "btnSubmit" runat= "server" Text= "Button" /> |
1 | <script type= "text/javascript" > |
2 | $(document).ready( function () { |
3 | $( "#btnSubmit" ).click( function () { |
4 | alert( "Alert using jQuery" ); |
5 | }); |
6 | }); |
7 | </script> |
Get label value:
1 | $( '#'+'<%=Label1.ClientID%>' ).text(); |
1 | $( '#'+'<%=Label1.ClientID%>' ).text( "New Value" ); |
1 | $( '#'+'<%=TextBox1.ClientID%>' ).val(); |
1 | $( '#'+'<%=TextBox1.ClientID%>' ).val( "New Value" ); |
1 | $( '#'+'<%=DropDownList1.ClientID%>' ).val(); |
1 | $( '#'+'<%=DropDownList1.ClientID%>' ).val( "New Value" ); |
1 | $( '#'+'<%=DropDownList1.ClientID%> option:selected' ).text(); |
1 | $( '#'+'<%=CheckBox1.ClientID%>' ).attr( 'checked' ); |
1 | $( '#'+'<%=CheckBox1.ClientID%>' ).attr( 'checked' , true ); |
1 | $( '#'+'<%=CheckBox1.ClientID%>' ).attr( 'checked' , false ); |
1 | $( '#'+'<%=RadioButton1.ClientID%>' ).attr( 'checked' ); |
1 | $( '#'+'<%=RadioButton1.ClientID%>' ).attr( 'checked' , true ); |
1 | $( '#'+'<%=RadioButton1.ClientID%>' ).attr( 'checked' , false ); |
1 | $( '#'+'<%=TextBox1.ClientID%>' ).attr( 'disabled' , true ); |
1 | $( '#'+'<%=TextBox1.ClientID%>' ).attr( 'disabled' , false ); |
1 | $( '#'+'<%=TextBox1.ClientID%>' ).attr( 'readonly' , 'readonly' ); |
No comments:
Post a Comment
Dharamart.blogspot.in