📄 radiobuttonlist.cs
字号:
using System;
using System.Collections.Specialized;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for RadioButtonList.
/// </summary>
public class RadioButtonList : ListControl,
IRepeatInfoUser,
System.Web.UI.INamingContainer,
System.Web.UI.IPostBackDataHandler
{
private short radioButtonTabIndex;
private bool selIndexChanged;
public RadioButtonList() : base()
{
this.selIndexChanged = false;
}
protected override Style CreateControlStyle()
{
return new TableStyle(this.ViewState);
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
RepeatInfo local0;
Style local1;
bool local2;
local0 = new RepeatInfo();
local1 = (this.ControlStyleCreated)? this.ControlStyle : null;
local2 = false;
this.radioButtonTabIndex = this.TabIndex;
if (this.radioButtonTabIndex != 0)
{
if (!(this.ViewState.IsItemDirty("TabIndex")))
local2 = true;
this.TabIndex = 0;
}
local0.RepeatColumns = this.RepeatColumns;
local0.RepeatDirection = this.RepeatDirection;
local0.RepeatLayout = this.RepeatLayout;
local0.RenderRepeater(writer, this, local1, this);
if (this.radioButtonTabIndex !=0)
this.TabIndex = this.radioButtonTabIndex;
if (local2)
this.ViewState.SetItemDirty("TabIndex", false);
}
bool System.Web.UI.IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
{
string local0;
int local1;
int local2;
int local3;
local0 = postCollection[postDataKey];
local1 = this.SelectedIndex;
local2 = this.Items.Count;
local3 = 0;
while (local3 < local2)
{
if ((local0 == this.Items[local3].Value))
{
if (local3 != local1)
{
this.selIndexChanged = true;
this.SelectedIndex = local3;
}
return true;
}
local3++;
}
return false;
}
void System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
{
if (this.selIndexChanged)
this.OnSelectedIndexChanged(System.EventArgs.Empty);
}
bool System.Web.UI.WebControls.IRepeatInfoUser.HasFooter
{
get
{
return false;
}
}
bool System.Web.UI.WebControls.IRepeatInfoUser.HasHeader
{
get
{
return false;
}
}
bool System.Web.UI.WebControls.IRepeatInfoUser.HasSeparators
{
get
{
return false;
}
}
int System.Web.UI.WebControls.IRepeatInfoUser.RepeatedItemCount
{
get
{
return this.Items.Count;
}
}
Style System.Web.UI.WebControls.IRepeatInfoUser.GetItemStyle(ListItemType itemType, int repeatIndex)
{
return null;
}
void System.Web.UI.WebControls.IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, System.Web.UI.HtmlTextWriter writer)
{
RadioButton local0;
local0 = new RadioButton();
local0._page = this.Page;
local0.GroupName = this.UniqueID;
local0.ID = this.ClientID + "_" + repeatIndex.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
local0.Text = this.Items[repeatIndex].Text;
local0.Attributes["value"] = this.Items[repeatIndex].Value;
local0.Checked = this.Items[repeatIndex].Selected;
local0.TextAlign = this.TextAlign;
local0.AutoPostBack = this.AutoPostBack;
local0.TabIndex = this.radioButtonTabIndex;
local0.RenderControl(writer);
}
public virtual int CellPadding
{
get
{
if (!(this.ControlStyleCreated))
return -1;
return ((TableStyle)this.ControlStyle).CellPadding;
}
set
{
((TableStyle) this.ControlStyle).CellPadding = value;
}
}
public virtual int CellSpacing
{
get
{
if (!(this.ControlStyleCreated))
return -1;
return ((TableStyle)this.ControlStyle).CellSpacing;
}
set
{
((TableStyle)this.ControlStyle).CellSpacing = value;
}
}
public virtual int RepeatColumns
{
get
{
object local0;
local0 = this.ViewState["RepeatColumns"];
if (local0 != null)
return (Int32) local0;
return 0;
}
set
{
if (value < 0)
throw new ArgumentOutOfRangeException("value");
this.ViewState["RepeatColumns"] = value;
}
}
public virtual RepeatDirection RepeatDirection
{
get
{
object local0;
local0 = this.ViewState["RepeatDirection"];
if (local0 != null)
return (RepeatDirection) local0;
return RepeatDirection.Vertical;
}
set
{
if ((value != RepeatDirection.Horizontal) && (value != RepeatDirection.Vertical))
throw new ArgumentOutOfRangeException("value");
this.ViewState["RepeatDirection"] = value;
}
}
public virtual RepeatLayout RepeatLayout
{
get
{
object local0;
local0 = this.ViewState["RepeatLayout"];
if (local0 != null)
return (RepeatLayout) local0;
return 0;
}
set
{
if ((value != RepeatLayout.Table) && (value != RepeatLayout.Flow))
throw new ArgumentOutOfRangeException("value");
this.ViewState["RepeatLayout"] = value;
}
}
public virtual TextAlign TextAlign
{
get
{
object local0;
local0 = this.ViewState["TextAlign"];
if (local0 != null)
return (TextAlign) local0;
return TextAlign.Right;
}
set
{
if((value != TextAlign.Left) && (value != TextAlign.Right))
throw new ArgumentOutOfRangeException("value");
this.ViewState["TextAlign"] = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -