Radiobutton怎么获取值
答案:2 悬赏:70 手机版
解决时间 2021-02-10 13:52
- 提问者网友:心如荒岛囚我终老
- 2021-02-09 14:37
Radiobutton怎么获取值
最佳答案
- 五星知识达人网友:思契十里
- 2021-02-09 15:15
string str=""; if(RadioButton1.Checked) { str=RadioButton1.text; } else if(RadioButton2.Checked) { str=RadioButton1.text; } else {lblMessage.text="请选择你的性别";}
全部回答
- 1楼网友:七十二街
- 2021-02-09 15:47
使用radiobuttonlist,这个连分组都省了,直接用radiobuttonlist.selecteditem.text取文本值,用radiobuttonlist.selectedvalue取value的值. 你上面那种写法,必须用for循环每一个radiobutton,还要判断哪个被选中,在取相应的文本。 页面端:<panel id= "panel1" runat= "server " <asp:radiobutton id= "radiobutton1 " runat= "server " text= "博士 " groupname= "know " </asp:radiobutton <asp:radiobutton id= "radiobutton2 " runat= "server " text= "硕士 " groupname= "know " </asp:radiobutton <asp:radiobutton id= "radiobutton3 " runat= "server " text= "本科 " groupname= "know " </asp:radiobutton <asp:radiobutton id= "radiobutton4 " runat= "server " text= "大专 " groupname= "know " </asp:radiobutton <asp:radiobutton id= "radiobutton5 " runat= "server " text= "中专 " groupname= "know " </asp:radiobutton </panel服务端:private string getselectnotevalue(){panel panel1 = new panel(); string strtext = string.empty; for (int i = 1; i <= 5; i++){radiobutton rbtn = (radiobutton)panel1.findcontrol("radiobutton" + i.tostring());
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯