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 short tabIndex;
\r
26 public RadioButtonList(): base()
\r
28 selectionIndexChanged = false;
\r
31 public virtual int CellPadding
\r
35 if(ControlStyleCreated)
\r
37 return (int)(((TableStyle)ControlStyle).CellPadding);
\r
43 ((TableStyle)ControlStyle).CellPadding = value;
\r
47 public virtual int CellSpacing
\r
51 if(ControlStyleCreated)
\r
53 return (int)(((TableStyle)ControlStyle).CellSpacing);
\r
59 ((TableStyle)ControlStyle).CellSpacing = value;
\r
63 public virtual int RepeatColumns
\r
67 object o = ViewState["RepeatColumns"];
\r
75 throw new ArgumentOutOfRangeException("value");
\r
76 ViewState["RepeatColumns"] = value;
\r
80 public virtual RepeatDirection RepeatDirection
\r
84 object o = ViewState["RepeatDirection"];
\r
86 return (RepeatDirection)o;
\r
87 return RepeatDirection.Vertical;
\r
91 if(!Enum.IsDefined(typeof(RepeatDirection), value))
\r
92 throw new ArgumentException();
\r
93 ViewState["RepeatDirection"] = value;
\r
97 public virtual RepeatLayout RepeatLayout
\r
101 object o = ViewState["RepeatLayout"];
\r
103 return (RepeatLayout)o;
\r
104 return RepeatLayout.Table;
\r
108 if(!Enum.IsDefined(typeof(RepeatLayout), value))
\r
109 throw new ArgumentException();
\r
110 ViewState["RepeatLayout"] = value;
\r
114 public virtual TextAlign TextAlign
\r
118 object o = ViewState["TextAlign"];
\r
120 return (TextAlign)o;
\r
121 return TextAlign.Right;
\r
125 if(!Enum.IsDefined(typeof(TextAlign), value))
\r
126 throw new ArgumentException();
\r
127 ViewState["TextAlign"] = value;
\r
131 protected override Style CreateControlStyle()
\r
133 return new TableStyle(ViewState);
\r
136 protected override void Render(HtmlTextWriter writer)
\r
138 RepeatInfo info = new RepeatInfo();
\r
139 Style cStyle = (ControlStyleCreated ? ControlStyle : null);
\r
140 bool dirty = false;
\r
141 tabIndex = TabIndex;
\r
144 dirty = !ViewState.IsItemDirty("TabIndex");
\r
147 info.RepeatColumns = RepeatColumns;
\r
148 info.RepeatDirection = RepeatDirection;
\r
149 info.RenderRepeater(writer, this, cStyle, this);
\r
152 TabIndex = tabIndex;
\r
156 ViewState.SetItemDirty("TabIndex", false);
\r
160 bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
\r
162 string value = postCollection[postDataKey];
\r
163 for(int i=0; i < Items.Count; i++)
\r
165 if(Items[i].Value == value)
\r
167 if(i != SelectedIndex)
\r
177 void IPostBackDataHandler.RaisePostDataChangedEvent()
\r
179 if(selectionIndexChanged)
\r
180 OnSelectedIndexChanged(EventArgs.Empty);
\r
183 Style IRepeatInfoUser.GetItemStyle(System.Web.UI.WebControls.ListItemType itemType, int repeatIndex)
\r
188 [MonoTODO("RadioButtonList_RenderItem")]
\r
189 void IRepeatInfoUser.RenderItem(System.Web.UI.WebControls.ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
\r
191 throw new NotImplementedException();
\r
194 bool IRepeatInfoUser.HasFooter
\r
202 bool IRepeatInfoUser.HasHeader
\r
210 bool IRepeatInfoUser.HasSeparators
\r
218 int IRepeatInfoUser.RepeatedItemCount
\r
222 return Items.Count;
\r