如何获取未选中的单选按钮的文本 [英] how to get the text of unselected radiobutton

查看:69
本文介绍了如何获取未选中的单选按钮的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取未选中的单选按钮的文本?

假设我们有3个单选按钮A,B和C.选择了A,但我想获取单选按钮C的文本.有人可以帮我吗?

How can I get the text of unselected radiobuttons?

Suppose we have 3 radiobuttons A, B and C. A is selected but I want to get the text of radiobutton C. Could anyone please help me with this?

推荐答案

您可以使用单选按钮的Text属性.例如您可以获取C单选按钮的文本,然后使用c.Text,其中c是单选按钮的名称.

请参阅 http://www.homeandlearn.co.uk/csharp/csharp_s4p12上的单选按钮和复选框的完整示例. .html [^ ]

希望这会有所帮助.
一切顺利.
You can use the Text property of the radio button. e.g. You can get the text of C radio button then use c.Text, where c is the name of the radio button.

Refer the full example of Radio Button and Check Box at http://www.homeandlearn.co.uk/csharp/csharp_s4p12.html[^]

Hope this helps.
All the best.


浏览页面中的所有单选按钮并获取其值.

Loop through all radio button in page and get it''s values.

 foreach (Control control in Page.Controls)
 {
     RadioButton  rbControl = control as RadioButton ;
     if (rbControl != null)
     {
         Page.Title =  rbControl.Text //get text of radio button
     }
}


这篇关于如何获取未选中的单选按钮的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆