Saturday, November 22, 2008

jQuery – working with ASP.NET controls

 

DropDownList SelectedValue:

GET:   $('#<%=DropDownList1.ClientID%>').val();
SET: $('#<%=DropDownList1.ClientID%>')
.val("value_to_set");

RadioButtonList SelectedValue:

$("input[name='<%=RadioButtonList1
.UniqueID%>']:checked").val();

Button Enable/Disable

$('#<%=Button1.ClientID%>').attr("disabled", true/false);

Label Text

GET:  $('#<%=Label1.ClientID%>').text();
SET: $('#<%=Label1.ClientID%>').text("value_to_set");

TextBox Text

GET:  $('#<%=TextBox1.ClientID%>').val();
SET: $('#<%=TextBox1.ClientID%>').val("value_to_set")

Check Visibility

if ($('#<%=Button1.ClientID%>').is(':visible'));

3 comments: