2010-11-17 21 views
1

我在窗體上有一個ASP.NET RadioButtonList,我想將它轉換爲它是一個像this這樣的JQuery按鈕。如何將RadioButtonList轉換爲JQuery UI按鈕列表?

我簡單的代碼:

<asp:Label ID="lblOrderType" Text="Order Type" runat="server" CssClass="label" /> 
<asp:RadioButtonList ID="radOrderType" runat="server" RepeatDirection="Horizontal" CssClass="radioButtonList"> 
    <asp:ListItem value="M" Selected="True">Market</asp:ListItem> 
    <asp:ListItem value="L">Limit</asp:ListItem> 
    <asp:ListItem value="S">Stop</asp:ListItem> 
</asp:RadioButtonList> 

<asp:Button 
    ID="btnInsert" 
    runat="server" 
    Text="Insert" 
    onclick="btnInsert_Click" CssClass="button" 
/> 

當btnInsert按鈕被點擊我要檢索選定的單選按鈕的值,但使用jQuery的按鈕。

protected void btnInsert_Click(object sender, EventArgs e) 
{ 
    // some database code 
    DB.Insert(radOrderType.SelectedValue); 
} 

我該怎麼做呢?

回答

2

假設你已經獲得了jQuery和jQuery UI的js文件的引用嘗試添加這對您的標記:

<script type="text/javascript"> 
$(document).ready(function() { $("#<%= radOrderType.ClientID %>").buttonset(); }); 
</script> 
+0

偉大的作品,謝謝! – 2010-11-17 15:51:22

+0

另一個小問題 - 我在FormView中有一個名爲fvwEdit的單選按鈕列表。我試過'$(document).ready(function(){$(「#<%= fvwEdit $ radOrderType.ClientID%>」)。buttonset();});'但是我得到一個錯誤。有任何想法嗎? – 2010-11-18 08:40:59

相關問題