.net中單選按鈕RadioButton,RadioButtonList 以及純Html中radio的用法實例?


.net中單選按鈕RadioButton,RadioButtonList 以及純Html中radio的用法,區別?


RadioButton實例及說明:

<asp:RadioButton ID="publicHas" Checked="true" runat="server" CssClass="radioMiddle" Text="所有人可見" GroupName="mm"/>
                                                                                                 
<asp:RadioButton ID="privateHas" runat="server" CssClass="radioMiddle" Text="僅自己可見"  GroupName="mm" />
                                   
<asp:RadioButton ID="friendHas" runat="server" CssClass="radioMiddle" Text="僅好友可見"   GroupName="mm" />
                                              
.net后台處理方式:                             
  if (privateHas.Checked == true)
     model.Limits = 0;
  if (friendHas.Checked == true)
     model.Limits = 1;
  if (publicHas.Checked == true)
     model.Limits = 2;


RadioButtonList在.net中跟DropDownList用法相似,可以看成集合:
 <asp:RadioButtonList ID="rbImg" Name="rbImg" runat="server" RepeatDirection="Horizontal"
         RepeatLayout="Flow">
      <asp:ListItem Value="1">是</asp:ListItem>
      <asp:ListItem Value="0" Selected="True">否</asp:ListItem>
 </asp:RadioButtonList>


.net后台處理方式:

  this.radCid.SelectedValue = project.Cid;
        


radio
將name設置為相同的值
<input type="radio" name="sex" value="1" checked="checked"></input><input type="radio" name="sex" value="0" ></input>女


.net后台處理方式:
通過Request.Form["sex"].ToString();獲取

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM