-/**\r
-* Namespace: System.Web.UI.WebControls\r
-* Class: CheckBoxList\r
-*\r
-* Author: Gaurav Vaish\r
-* Maintainer: gvaish@iitk.ac.in\r
-* Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
-* Implementation: yes\r
-* Status: 80%\r
-*\r
-* (C) Gaurav Vaish (2001)\r
-*/\r
+//
+// System.Web.UI.WebControls.CheckBoxList.cs
+//
+// Authors:
+// Gaurav Vaish (gvaish@iitk.ac.in)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) Gaurav Vaish (2002)
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
\r
using System;\r
using System.Collections.Specialized;\r
+using System.ComponentModel;\r
using System.Globalization;\r
using System.Web;\r
using System.Web.UI;\r
{\r
CheckBox checkBoxRepeater;\r
bool isChangeNotified;\r
- \r
+\r
public CheckBoxList()\r
{\r
checkBoxRepeater = new CheckBox();\r
checkBoxRepeater.ID = "0";\r
checkBoxRepeater.EnableViewState = false;\r
- checkBoxRepeater.Controls.Add(this);\r
+ Controls.Add (checkBoxRepeater);\r
isChangeNotified = false;\r
}\r
- \r
+
+ [DefaultValue (-1), Bindable (true), WebCategory ("Layout")]
+ [WebSysDescription ("The border left within a CheckBox.")]\r
public virtual int CellPadding\r
{\r
get\r
((TableStyle)ControlStyle).CellPadding = value;\r
}\r
}\r
- \r
+
+ [DefaultValue (-1), Bindable (true), WebCategory ("Layout")]
+ [WebSysDescription ("The border left between CheckBoxes.")]\r
public virtual int CellSpacing\r
{\r
get\r
((TableStyle)ControlStyle).CellSpacing = value;\r
}\r
}\r
- \r
+
+ [DefaultValue (0), Bindable (true), WebCategory ("Layout")]
+ [WebSysDescription ("The number of columns that should be used to display the CheckBoxes.")]\r
public virtual int RepeatColumns\r
{\r
get\r
ViewState["RepeatColumns"] = value;\r
}\r
}\r
- \r
+
+ [DefaultValue (typeof (RepeatDirection), "Vertical"), Bindable (true), WebCategory ("Layout")]
+ [WebSysDescription ("The direction that is followed when doing the layout.")]\r
public virtual RepeatDirection RepeatDirection\r
{\r
get\r
ViewState["RepeatDirection"] = value;\r
}\r
}\r
- \r
+
+ [DefaultValue (typeof (RepeatLayout), "Table"), Bindable (true), WebCategory ("Layout")]
+ [WebSysDescription ("The method used to create the layout.")]\r
public virtual RepeatLayout RepeatLayout\r
{\r
get\r
ViewState["RepeatLayout"] = value;\r
}\r
}\r
- \r
+
+ [DefaultValue (typeof (TextAlign), "Right"), Bindable (true), WebCategory ("Appearance")]
+ [WebSysDescription ("The alignment of the CheckBox text.")]\r
public virtual TextAlign TextAlign\r
{\r
get\r
ViewState["TextAlign"] = value;\r
}\r
}\r
- \r
+\r
protected override Style CreateControlStyle()\r
{\r
- // I have to return a TableStyle\r
return new TableStyle(ViewState);\r
}\r
- \r
+\r
protected override Control FindControl(string id, int pathOffset)\r
{\r
return this;\r
}\r
- \r
+\r
protected override void OnPreRender(EventArgs e)\r
{\r
checkBoxRepeater.AutoPostBack = AutoPostBack;\r
{\r
if(Items[i].Selected)\r
{\r
- // register each selected with the ID\r
checkBoxRepeater.ID = i.ToString(NumberFormatInfo.InvariantInfo);\r
Page.RegisterRequiresPostBack(checkBoxRepeater);\r
}\r
}\r
}\r
}\r
- \r
- [MonoTODO]\r
+\r
protected override void Render(HtmlTextWriter writer)\r
{\r
- throw new NotImplementedException();\r
+ RepeatInfo ri = new RepeatInfo();\r
+ checkBoxRepeater.TabIndex = TabIndex;\r
+ bool dirtyFlag = false;\r
+ short tTabIndex = TabIndex;\r
+ Style s = (ControlStyleCreated ? ControlStyle : null);\r
+ if(TabIndex != 0)\r
+ {\r
+ if(!ViewState.IsItemDirty("TabIndex"))\r
+ dirtyFlag = true;\r
+ TabIndex = 0;\r
+ }\r
+ ri.RepeatColumns = RepeatColumns;\r
+ ri.RepeatLayout = RepeatLayout;\r
+ ri.RepeatDirection = RepeatDirection;\r
+ ri.RenderRepeater(writer, this, s, this);\r
+ if(tTabIndex != 0)\r
+ {\r
+ TabIndex = tTabIndex;\r
+ }\r
+ if(dirtyFlag)\r
+ {\r
+ ViewState.SetItemDirty("TabIndex", false);\r
+ }\r
}\r
- \r
- bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)\r
- {\r
+
+ bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+ {
+ if (!Enabled)
+ return false;
+
int index = Int32.Parse(postDataKey.Substring(UniqueID.Length + 1));\r
- if(index >= 0 && index < Items.Count)\r
- {\r
- bool exists = (postCollection[postDataKey]!=null);\r
+ if(index >= 0 && index < Items.Count)
+ {
+ string v = postCollection [postDataKey];
+ bool exists = (v != null);
if(Items[index].Selected != exists)\r
{\r
Items[index].Selected = exists;\r
}\r
return false;\r
}\r
- \r
- [MonoTODO]\r
+\r
void IPostBackDataHandler.RaisePostDataChangedEvent()\r
{\r
- throw new NotImplementedException();\r
+ OnSelectedIndexChanged(EventArgs.Empty);\r
}\r
- \r
+\r
bool IRepeatInfoUser.HasFooter\r
{\r
get\r
return false;\r
}\r
}\r
- \r
+\r
bool IRepeatInfoUser.HasHeader\r
{\r
get\r
return false;\r
}\r
}\r
- \r
+\r
bool IRepeatInfoUser.HasSeparators\r
{\r
get\r
return false;\r
}\r
}\r
- \r
+\r
int IRepeatInfoUser.RepeatedItemCount\r
{\r
get\r
return Items.Count;\r
}\r
}\r
- \r
- // I don't need this\r
+\r
Style IRepeatInfoUser.GetItemStyle(ListItemType itemType, int repeatIndex)\r
{\r
return null;\r
}\r
- \r
+\r
void IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)\r
{\r
checkBoxRepeater.ID = repeatIndex.ToString(NumberFormatInfo.InvariantInfo);\r
checkBoxRepeater.Text = Items[repeatIndex].Text;\r
checkBoxRepeater.TextAlign = TextAlign;\r
checkBoxRepeater.Checked = Items[repeatIndex].Selected;\r
+ checkBoxRepeater.Enabled = Enabled;\r
checkBoxRepeater.RenderControl(writer);\r
}\r
}\r