单项选择的 提交按键代码
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked == false & RadioButton2.Checked == false & RadioButton3.Checked == false & RadioButton4.Checked == false)
Label1.Text = "请输入您的选项";
else
{
if (RadioButton1.Checked == true)
Label1.Text = RadioButton1.Text;
else
{
if (RadioButton2.Checked == true)
Label1.Text = RadioButton2.Text;
else
{
if (RadioButton3.Checked == true)
Label1.Text = RadioButton3.Text;
checkbox和radiobutton的区别 else
{
if (RadioButton3.Checked == true)
Label1.Text = RadioButton4.Text;
}
}
}
}
}
Dropdownlist按键代码
protected void Button7_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue;
}
Listbox 页面代码(含按键)
public partial class ListBox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (ListBox1.SelectedIndex == 0)
ListBox2.SelectionMode = ListSelectionMode.Single;
else
ListBox2.SelectionMode = ListSelectionMode.Multiple;
}
protected void Button7_Click(object sender, EventArgs e)
{
Label1.Text = "";
foreach (ListItem li in ListBox2.Items)
{
if (li.Selected == true)
Label1.Text += li.Text;
}
}
}
单项列表按键代码
protected void Button1_Click(object sender, EventArgs e)
{
//if (!IsPostBack)
//{
// RadioButtonList1.Items.
//}
Label1.Text = string.Empty;
Label1.Text = RadioButtonList1.SelectedItem.Text;
}
多项选择提交按键
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = string.Empty;
if (CheckBox1.Checked == true)
Label1.Text += CheckBox1.Text;
if (CheckBox2.Checked == true)
Label1.Text += CheckBox2.Text;
if (CheckBox3.Checked == true)
Label1.Text += CheckBox3.Text;
if (CheckBox4.Checked == true)
Label1.Text += CheckBox4.Text;
if (CheckBox5.Checked == true)
Label1.Text += CheckBox5.Text;
//else
// Label1.Text = "请输入您的选项";
}
多项列表提交按键
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = string.Empty;
foreach(ListItem li in CheckBoxList1.Items)
{
if (li.Selected == true)
Label1.Text +=li.Text;
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论