jquery select item in radiobuttonlist via client-side function

Posted by mcliedtk on Stack Overflow See other posts from Stack Overflow or by mcliedtk
Published on 2010-03-18T22:54:39Z Indexed on 2010/03/18 23:11 UTC
Read the original article Hit count: 550

Filed under:
|
|

I have the following ASP.NET RadioButtonList:

<asp:RadioButtonList ID="rbl" runat="server">
    <asp:ListItem Text="Type1" Value="1" />
    <asp:ListItem Text="Type2" Value="2" />
</asp:RadioButtonList>

I would like to select an item in the list programmatically via a client-side jquery function like this (simplified version):

function BindWidget(widget) {
    // Type property of Widget is an int.
    $("#<%=rbl.ClientID%>").selectItemByValue(widget.Type);
}

Ideally, there is some function - in the above code I have proposed selectItemByValue - that selects an item in a RadioButtonList by a given value. Does jquery have a similar function built-in? If not, how should I go about implementing the desired functionality?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ASP.NET