2 * Namespace: System.Web.UI.WebControls
\r
3 * Class: RadioButtonList
\r
5 * Author: Gaurav Vaish
\r
6 * Maintainer: gvaish@iitk.ac.in
\r
7 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
\r
8 * Implementation: yes
\r
11 * (C) Gaurav Vaish (2002)
\r
15 using System.Collections.Specialized;
\r
17 using System.Web.UI;
\r
19 namespace System.Web.UI.WebControls
\r
21 public class RadioButtonList : ListControl, IRepeatInfoUser, INamingContainer, IPostBackDataHandler
\r
23 private bool selectionIndexChanged;
\r
24 private int tabIndex;
\r
26 public RadioButtonList(): base()
\r
28 selectionIndexChanged = false;
\r
31 public virtual int CellPadding
\r
35 if(ControlStyleCreated)
\r
36 return (int)(((TableStyle)ControlStyle).CellPadding);
\r
40 ((TableStyle)ControlStyle).CellPadding = value;
\r
44 public virtual int CellSpacing
\r
48 if(ControlStyleCreated)
\r
49 return (int)(((TableStyle)ControlStyle).CellSpacing);
\r
53 ((TableStyle)ControlStyle).CellSpacing = value;
\r
57 public virtual int RepeatColumns
\r
61 object o = ViewState["RepeatColumns"];
\r
69 throw new ArgumentOutOfRangeException("value");
\r
70 ViewState["RepeatColumns"] = value;
\r
74 public virtual RepeatDirection RepeatDirection
\r
78 object o = ViewState["RepeatDirection"];
\r
80 return (RepeatDirection)o;
\r
81 return RepeatDirection.Vertical;
\r
85 if(!Enum.IsDefined(typeof(RepeatDirection), value))
\r
86 throw new ArgumentException();
\r
87 ViewState["RepeatDirection"] = value;
\r
91 public virtual RepeatLayout RepeatLayout
\r
95 object o = ViewState["RepeatLayout"];
\r
97 return (RepeatLayout)o;
\r
98 return RepeatLayout.Table;
\r
102 if(!Enum.IsDefined(typeof(RepeatLayout), value))
\r
103 throw new ArgumentException();
\r
104 ViewState["RepeatLayout"] = value;
\r
108 public virtual TextAlign TextAlign
\r
112 object o = ViewState["TextAlign"];
\r
114 return (TextAlign)o;
\r
115 return TextAlign.Right;
\r
119 if(!Enum.IsDefined(typeof(TextAlign), value))
\r
120 throw new ArgumentException();
\r
121 ViewState["TextAlign"] = value;
\r
125 protected override Style CreateControlStyle()
\r
127 return new TableStyle(ViewState);
\r
130 protected override void Render(HtmlTextWriter writer)
\r
132 RepeatInfo info = new RepeatInfo();
\r
133 Style cStyle = (ControlStyleCreated ? ControlStyle : null);
\r
134 bool dirty = false;
\r
135 tabIndex = TabIndex;
\r
138 dirty = !ViewState.IsItemDirty("TabIndex");
\r
141 info.RepeatColumns = RepeatColumns;
\r
142 info.RepeatDirection = RepeatDirection;
\r
143 info.RenderRepeater(writer, this, cStyle, this);
\r
146 TabIndex = tabIndex;
\r
150 ViewState.SetItemDirty("TabIndex", false);
\r
154 bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
\r
156 string value = postCollection[postDataKey];
\r
157 for(int i=0; i < Items.Count; i++)
\r
159 if(Items[i].Value == value)
\r
161 if(i != SelectedIndex)
\r
171 void IPostBackDataHandler.RaisePostDataChangedEvent()
\r
173 if(selectionIndexChanged)
\r
174 OnSelectedIndexChanged(EventArgs.Empty);
\r
177 Style IRepeatInfoUser.GetItemStyle(System.Web.UI.WebControls.ListItemType itemType, int repeatIndex)
\r
182 [MonoTODO("RadioButtonList_RenderItem")]
\r
183 void IRepeatInfoUser.RenderItem(System.Web.UI.WebControls.ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
\r
185 throw new NotImplementedException();
\r
188 bool IRepeatInfoUser.HasFooter
\r
196 bool IRepeatInfoUser.HasHeader
\r
204 bool IRepeatInfoUser.HasSeparators
\r
212 int IRepeatInfoUser.RepeatedItemCount
\r
216 return Items.Count;
\r