2016-08-22 51 views
2

我是編程新手,這是我的第一個問題,我希望按照規則做。 我想放置單選按鈕,並在他們旁邊的文本框。我明白,我不能用單選按鈕列表。像這樣: Radio Buttons on the right side of the text 什麼是最好的方式來做到這一點,以及如何將它們分組?此外,我想檢查哪些按鈕被檢查並保存這些信息。 我會感激任何建議,以正確的方式來做到這一點。沒有列表的組單選按鈕

+0

您可以嘗試單選按鈕GroupName屬性。 –

+0

目前尚不清楚您想要達到的目標以及您遇到什麼問題。你有沒有理由不能使用RadioButtonList?您將不得不手動執行所選RadioButton和相應文本框中文本之間的映射。我不認爲有內置的方式來做到這一點。 –

+0

現在我使用單選按鈕和GroupName,但在我的代碼後面,我使用if-else結構來查找哪個按鈕被選中並將其映射到文本框。我想也許有更有效的方法來做到這一點。 – InnaS

回答

0

試試這個:

您可以使用單選按鈕的GroupName物業這樣做......

例如:

<asp:RadioButton id="Radio1" GroupName="radio" runat="server"/> 
<asp:RadioButton id="Radio2" GroupName="radio" runat="server"/> 
<asp:RadioButton id="Radio3" GroupName="radio" runat="server"/> 

然後你可以訪問這個電臺代碼背後的按鈕。

如需進一步參考link

0

這可以幫助你使用輸入組將單選按鈕與文本引導

<link href="http://v4-alpha.getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"> 
    <div class="col-lg-6"> 
      <div class="input-group"> 
       <span class="input-group-addon"> 
       <input type="radio" aria-label="Radio button for following text input"> 
       </span> 
       <span class="input-group-addon"> 
       Your Text 
       </span> 
       <input type="text" class="form-control" aria-label="Text input with radio button"> 
      </div> 
      </div> 
+0

謝謝,看起來非常好。我正在尋找將其鏈接到背後的代碼的方式。 – InnaS