我有兩個用於公制和美式測量的單選按鈕。我加載頁面,以便點擊公制單選按鈕。如何設置這兩個按鈕,以便在單擊美國時公制單擊和反之亦然?兩個單選按鈕ASP.NET C#
24
A
回答
2
將兩個單選按鈕的GroupName
屬性設置爲相同的值。您也可以嘗試使用RadioButtonGroup
,它會自動爲您做到這一點。
14
確保其GroupName
屬性設置爲同一個名字:
<asp:RadioButton GroupName="MeasurementSystem" runat="server" Text="US" />
<asp:RadioButton GroupName="MeasurementSystem" runat="server" Text="Metric" />
3
<asp:RadioButtonList id="RadioButtonList1" runat="server">
<asp:ListItem Selected="True">Metric</asp:ListItem>
<asp:ListItem>US</asp:ListItem>
</asp:RadioButtonList>
46
爲了使其工作,你必須兩個單選按鈕的屬性組名設置爲相同的值:
<asp:RadioButton id="rbMetric" runat="server" GroupName="measurementSystem"></asp:RadioButton>
<asp:RadioButton id="rbUS" runat="server" GroupName="measurementSystem"></asp:RadioButton>
就個人而言,我更喜歡用一個單選按鈕列表:
<asp:RadioButtonList ID="rblMeasurementSystem" runat="server">
<asp:ListItem Text="Metric" Value="metric" />
<asp:ListItem Text="US" Value="us" />
</asp:RadioButtonList>
6
我可以看到這是一個老問題,如果你想把其他的HTML裏面可以使用與GroupName單選按鈕相同的所有單選按鈕,並在文本屬性設置類似的圖像或您需要的HTML。
<asp:RadioButton GroupName="group1" runat="server" ID="paypalrb" Text="<img src='https://www.paypalobjects.com/webstatic/mktg/logo/bdg_secured_by_pp_2line.png' border='0' alt='Secured by PayPal' style='width: 103px; height: 61px; padding:10px;'>" />
相關問題
- 1. 兩個單選按鈕一次選擇
- 2. 選擇兩個單選按鈕
- 3. c#ASP.NET Datalist和HTML單選按鈕
- 4. 同時選擇兩個單選按鈕
- 5. ASP.Net c#給定GroupName中的哪個單選按鈕被選中?
- 6. ASP.NET單選按鈕更改
- 7. ASP.NET中的單選按鈕
- 8. asp.net單選按鈕分組
- 9. asp.net gridview單選按鈕
- 10. 單選按鈕驗證(asp.net)
- 11. ASP.Net單選按鈕列表
- 12. 單選按鈕組asp.net
- 13. 用一個按鈕提交多個單選按鈕值ASP.NET MVC
- 14. asp.net與單選按鈕的多個gridviews
- 15. ASP.net C#按鈕單擊
- 16. 兩個回發按鈕ASP.NET
- 17. 單選按鈕值兩難
- 18. 同時點擊兩個單選按鈕?
- 19. 兩個單選按鈕不正確
- 20. 單選按鈕列表和單選按鈕asp.net
- 21. 從單選按鈕asp.net中檢索多個模型值c#mvc4
- 22. 微分單選按鈕,我不能區分兩個不同的單選按鈕
- 23. 使用jquery單選按鈕顯示懸停之間的兩個單選按鈕
- 24. 單選按鈕搜索結合兩個參數C#Lambda
- 25. ASP.Net 4.0中的單選按鈕選擇
- 26. C#單選按鈕測驗
- 27. 單選按鈕使用C#
- 28. 從單選按鈕C#
- 29. 單選按鈕列表上ASP.NET(VB)
- 30. C#幫助爲菜單添加單選按鈕/選項按鈕
使用單選按鈕列表http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.aspx – 2011-02-28 17:55:01
單選按鈕列表不允許內任何其他HTML雖然比其他ListItem爲每個單選按鈕。 – 2012-04-11 09:58:41