Asp.net 用switch 判断radiobutton被选中执行对应方法如何写?
2个回答
展开全部
例如radiobutton 控件名为 rd1 再加一个text控件名字叫textbox3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class 知道测试 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
Boolean bl;
bl = RadioButton1.Checked;
int i;
if (bl == true)
{
i = 1;
}
else {
i=2;
}
switch (i) {
case 1:
{
TextBox3.Text ="这个case里面就可以写你想要执行的程序了。";
}
break;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class 知道测试 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
Boolean bl;
bl = RadioButton1.Checked;
int i;
if (bl == true)
{
i = 1;
}
else {
i=2;
}
switch (i) {
case 1:
{
TextBox3.Text ="这个case里面就可以写你想要执行的程序了。";
}
break;
}
}
}
展开全部
int num=-1 ;
if (RadioButton1.Checked)
{
num = 1;
}
if (RadioButton2.Checked)
{
num = 2;
}
switch (num)
{
case 1: Response.Write("您选择RadioButton1"); break;
case 2: Response.Write("您选择RadioButton2"); break;
default:break;
}
if (RadioButton1.Checked)
{
num = 1;
}
if (RadioButton2.Checked)
{
num = 2;
}
switch (num)
{
case 1: Response.Write("您选择RadioButton1"); break;
case 2: Response.Write("您选择RadioButton2"); break;
default:break;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询