FineUI/FineUI.Examples/form/radiobutton.aspx.cs
2013-11-01 14:13:51 +08:00

71 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUI.Examples.form
{
public partial class radiobutton : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSelectSingleRadio_Click(object sender, EventArgs e)
{
rbtnSingleRadio.Checked = !rbtnSingleRadio.Checked;
}
protected void btnSelectSecondRadio_Click(object sender, EventArgs e)
{
String[] radios = new String[] { "rbtnFirst", "rbtnSecond", "rbtnThird" };
for (int i = 0; i < radios.Length; i++)
{
if ((SimpleForm1.FindControl(radios[i]) as RadioButton).Checked)
{
int next = i + 1;
if (next >= radios.Length)
{
next = 0;
}
(SimpleForm1.FindControl(radios[next]) as RadioButton).Checked = true;
break;
}
}
}
protected void rbtnAuto_CheckedChanged(object sender, CheckedEventArgs e)
{
// 单选框按钮的CheckedChanged事件会触发两次一次是取消选中的菜单项另一次是选中的菜单项
// 不处理取消选中菜单项的事件,从而防止此函数重复执行两次
if (!e.Checked)
{
return;
}
string checkedValue = String.Empty;
if (rbtnFirstAuto.Checked)
{
checkedValue = rbtnFirstAuto.Text;
}
else if (rbtnSecondAuto.Checked)
{
checkedValue = rbtnSecondAuto.Text;
}
else if (rbtnThirdAuto.Checked)
{
checkedValue = rbtnThirdAuto.Text;
}
Alert.ShowInTop("单选框选中项:" + checkedValue);
}
}
}