Files
mono/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
T
Dick Porter 3ff73d8d7d 2005-07-27 Dick Porter <[email protected]>
* HtmlInputCheckBoxTest.cs: Tests for HtmlInputCheckBox

2005-07-26  Dick Porter  <[email protected]>

	* HtmlSelectTest.cs: Tests for HtmlSelect

2005-07-21  Dick Porter  <[email protected]>

	* HtmlImageTest.cs: The order of attribute rendering has changed,
	and now matches MS

2005-07-19  Dick Porter  <[email protected]>

	* HtmlImageTest.cs: Added tests for negative values in int
	properties

2005-07-14  Dick Porter  <[email protected]>

	* HtmlFormTest.cs: New set of tests

2005-07-07  Dick Porter  <[email protected]>

	* HtmlImageTest.cs: Unit tests for HtmlImage

2005-08-04  Dick Porter  <[email protected]>

	* DataGridColumnTest.cs: Tests for DataGridColumn

2005-07-29  Dick Porter  <[email protected]>

	* RadioButtonTest.cs: Added tests for RadioButton

2005-07-14  Dick Porter  <[email protected]>

	* CheckBoxTest.cs: Added enum checks

2005-07-13  Dick Porter  <[email protected]>

	* CheckBoxTest.cs: Added tests for CheckBox - currently all
	passing on mono and ms runtimes.

2005-07-14  Dick Porter  <[email protected]>

	* HttpPostedFile.cs: New basic implementation; needs someone to
	figure out what a HttpRequestStream does

2005-08-18  Dick Porter  <[email protected]>

	* HtmlTable.cs, HtmlInputButton.cs, HtmlInputFile.cs, HtmlHead.cs,
	HtmlInputImage.cs, HtmlForm.cs, HtmlInputText.cs,
	HtmlInputCheckBox.cs, HtmlAnchor.cs, HtmlInputRadioButton.cs,
	HtmlButton.cs, HtmlInputHidden.cs, HtmlTextArea.cs,
	HtmlTableRow.cs, HtmlSelect.cs, HtmlControl.cs, HtmlTitle.cs,
	HtmlContainerControl.cs: 2.0 API fixes and stubs and attribute fixes

2005-08-09  Dick Porter  <[email protected]>

	* HtmlSelect.cs: Clear databindings when adding a new one; cope
	with assorted combinations of empty text and value fields; write
	<option> tags manually to match ms HTML output.  All fix nunit
	tests.

2005-08-05  Dick Porter  <[email protected]>

	* HtmlSelect.cs: Fix databinding when one or other of Name and
	Value aren't supplied (thanks to Peter for the patch); Make
	<option> indenting match ms output.

2005-07-29  Dick Porter  <[email protected]>

	* HtmlForm.cs: Simplify the rendering code by using QueryStringRaw
	instead of building the query string by hand

2005-07-27  Dick Porter  <[email protected]>

	* HtmlInputCheckBox.cs: New implementation

2005-07-26  Dick Porter  <[email protected]>

	* HtmlSelect.cs: New implementation

2005-07-24  Dick Porter  <[email protected]>

	* HtmlForm.cs: Add the trailing query string to the form action;
	fixes bug shown in Test/standalone/htmlform/qs_postback.aspx

2005-07-22  Dick Porter  <[email protected]>

	* HtmlInputFile.cs: Add assembly attributes

2005-07-21  Dick Porter  <[email protected]>

	* HtmlImage.cs: The src attribute needs to be a relative URL;
	close the HTML element when rendering attributes, to match the MS
	impl.

	* HtmlForm.cs: Added assembly attributes; don't render ID twice;
	don't render enctype and target if they are empty strings;
	implement a Render overload to keep corcompare quiet.

2005-07-19  Dick Porter  <[email protected]>

	* HtmlImage.cs: Added attributes; use Int32.Parse instead of
	Convert.ToInt32

2005-07-14  Dick Porter  <[email protected]>

	* HtmlInputFile.cs: New implementation

2005-07-14  Dick Porter  <[email protected]>

	* HtmlForm.cs: New Implementation

2005-07-07  Dick Porter  <[email protected]>

	* HtmlImage.cs: New implementation

2005-08-18  Dick Porter  <[email protected]>

	* ControlCachePolicy.cs, PersistChildrenAttribute.cs,
	UserControl.cs, DesignerDataBoundLiteralControl.cs,
	PageStatePersister.cs, DataBoundLiteralControl.cs, Control.cs,
	BasePartialCachingControl.cs, LiteralControl.cs: 2.0 API fixes and
	stubs and attribute fixes

2005-08-11  Dick Porter  <[email protected]>

	* CssStyleCollection.cs: Tweak the css string format to pass a
	unit test

	* AttributeCollection.cs: Don't NRE if someone sets the "style"
	attribute to null.

2005-08-05  Dick Porter  <[email protected]>

	* HtmlTextWriter.cs: Make <option> tags render inline, to match
	the ms output

2005-07-07  Dick Porter  <[email protected]>

	* StateBag.cs: Added internal SetDirty (void) method to fix the
	build

2005-08-18  Dick Porter  <[email protected]>

	* PageAdapter.cs, ControlAdapter.cs: 2.0 stubs

2005-08-18  Dick Porter  <[email protected]>

	* Consts.cs: Added System.Web and Microsoft.VisualStudio.Web
	constants for 2.0

2005-08-18  Dick Porter  <[email protected]>

	* Button.cs, DetailsView.cs, Xml.cs, Table.cs, Menu.cs,
	DataControlButton.cs, Label.cs, ObjectDataSource.cs, CheckBox.cs,
	RadioButton.cs, ListControl.cs, Image.cs, SiteMapPath.cs,
	BaseDataList.cs, DataList.cs, BulletedList.cs,
	DataBoundControl.cs, Login.cs, GridView.cs,
	CompositeDataBoundControl.cs, Wizard.cs, BaseValidator.cs,
	TextBox.cs, CheckBoxList.cs, RadioButtonList.cs, FormView.cs,
	AdRotator.cs, Repeater.cs, MenuItemTemplateContainer.cs,
	DropDownList.cs, HyperLink.cs, ImageMap.cs, MultiView.cs,
	CompositeControl.cs, HierarchicalDataBoundControl.cs, Calendar.cs,
	ListBox.cs, TableCell.cs, WebControl.cs, Literal.cs,
	BaseDataBoundControl.cs, ValidationSummary.cs, ImageButton.cs,
	LinkButton.cs, TreeView.cs: 2.0 API fixes and stubs, and attribute
	fixes

2005-08-11  Dick Porter  <[email protected]>

	* CheckBox.cs: Let ViewState manage removals; apply styles and
	"style" attributes in a surrounding <span>.  Fixes unit tests.

2005-08-05  Dick Porter  <[email protected]>

	* CheckBox.cs: Shut corcompare up a bit more.  Still need to
	figure out how to not use AddAttributesToRender to get it
	completely silent.

	* ButtonColumn.cs: Implement Initialize() and InitializeCell()

	* DataGridColumn.cs: Added the duplicate viewstate manipulation
	methods

2005-08-04  Dick Porter  <[email protected]>

	* DataGridColumn.cs: New implementation

	* DataGrid.cs: 
	* DataGridColumnCollection.cs: Set the DataGridColumn's owner

2005-07-29  Dick Porter  <[email protected]>

	* RadioButton.cs: Hide nonstandard API; remove GroupName from the
	ViewState when it is null.

	* CheckBox.cs: Hide nonstandard API

2005-07-22  Dick Porter  <[email protected]>

	* BoundColumn.cs: 
	* ButtonColumn.cs: Initial stubs

2005-07-22  Dick Porter  <[email protected]>

	* RadioButton.cs:
	* CheckBox.cs: Add assembly attributes

2005-07-13  Dick Porter  <[email protected]>

	* CheckBox.cs: Reverted Ben's enum-to-int ViewState change, remove
	null Text properties from the ViewState, test for TextAlign being
	out of range.  All to make tests pass on both mono and ms
	runtimes.

2005-07-12  Dick Porter  <[email protected]>

	* RadioButton.cs: New implementation

	* CheckBox.cs: Rearrange the attributes rendering to allow
	RadioButton to derive from this

2005-07-11  Dick Porter  <[email protected]>

	* CheckBox.cs: New implementation

	* RadioButton.cs: Initial stubbed version that just compiles

2005-07-08  Dick Porter  <[email protected]>

	* TextAlign.cs: 
	* BorderStyle.cs: Added

svn path=/trunk/mcs/; revision=48915
2005-08-26 22:21:30 +00:00

395 lines
8.7 KiB
C#

//
// System.Web.UI.WebControls.CheckBox.cs
//
// Author:
// Dick Porter <[email protected]>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// 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.
//
using System.Web.UI;
using System.Collections.Specialized;
using System.ComponentModel;
namespace System.Web.UI.WebControls {
[Designer ("System.Web.UI.Design.WebControls.CheckBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[DataBindingHandler ("System.Web.UI.Design.TextDataBindingHandler, " + Consts.AssemblySystem_Design)]
[DefaultEvent ("CheckedChanged")]
[DefaultProperty ("Text")]
#if NET_2_0
[ControlValueProperty ("Checked", null)]
#endif
public class CheckBox : WebControl, IPostBackDataHandler
#if NET_2_0
, ICheckBoxControl
#endif
{
string render_type;
public CheckBox () : base (HtmlTextWriterTag.Input)
{
render_type = "checkbox";
}
internal CheckBox (string render_type) : base (HtmlTextWriterTag.Input)
{
this.render_type = render_type;
}
[DefaultValue (false)]
#if NET_2_0
[Themeable (false)]
#endif
public virtual bool AutoPostBack
{
get {
return (ViewState.GetBool ("AutoPostBack",
false));
}
set {
ViewState["AutoPostBack"] = value;
}
}
#if NET_2_0
[DefaultValue (false)]
[Themeable (false)]
[MonoTODO]
public virtual bool CausesValidation
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
#endif
[DefaultValue (false)]
#if NET_2_0
[Bindable (true, BindingDirection.TwoWay)]
[Themeable (false)]
#else
[Bindable (true)]
#endif
public virtual bool Checked
{
get {
return (ViewState.GetBool ("Checked", false));
}
set {
ViewState["Checked"] = value;
}
}
#if NET_2_0
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[MonoTODO]
public AttributeCollection InputAttributes
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[MonoTODO]
public AttributeCollection LabelAttributes
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
#endif
[DefaultValue ("")]
[Bindable (true)]
#if NET_2_0
[Localizable (true)]
#endif
public virtual string Text
{
get {
return (ViewState.GetString ("Text",
String.Empty));
}
set {
ViewState["Text"] = value;
}
}
[DefaultValue (TextAlign.Right)]
#if ONLY_1_1
[Bindable (true)]
#endif
public virtual TextAlign TextAlign
{
get {
object o = ViewState["TextAlign"];
if (o == null) {
return (TextAlign.Right);
} else {
return ((TextAlign)o);
}
}
set {
if (value != TextAlign.Left &&
value != TextAlign.Right) {
throw new ArgumentOutOfRangeException ("value");
}
ViewState["TextAlign"] = value;
}
}
#if NET_2_0
[Themeable (false)]
[DefaultValue ("")]
[MonoTODO]
public string ValidationGroup
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
#endif
private static readonly object EventCheckedChanged = new object ();
public event EventHandler CheckedChanged
{
add {
Events.AddHandler (EventCheckedChanged, value);
}
remove {
Events.RemoveHandler (EventCheckedChanged, value);
}
}
protected virtual void OnCheckedChanged (EventArgs e)
{
EventHandler handler = (EventHandler)Events[EventCheckedChanged];
if (handler != null) {
handler (this, e);
}
}
internal virtual string NameAttribute
{
get {
return (this.UniqueID);
}
}
protected override void AddAttributesToRender (HtmlTextWriter w)
{
if (Page != null)
Page.VerifyRenderingInServerForm (this);
/* This is a nasty kludge to avoid rendering
* "style" and the ControlStyle in checkboxes
* (we use a surrounding <span> instead), but
* still pass the unit test that shows the
* style being rendered in multiple calls to
* Render () (which means we can't just delete
* Attributes["style"] or ControlStyle.Reset()
* in Render ())
*/
string css_style = Attributes ["style"];
if (css_style != null) {
Attributes.Remove ("style");
}
Style style = new Style ();
if (ControlStyleCreated) {
style.CopyFrom (ControlStyle);
ControlStyle.Reset ();
}
base.AddAttributesToRender (w);
if (css_style != null) {
Attributes ["style"] = css_style;
}
if (!style.IsEmpty) {
ApplyStyle (style);
}
InternalAddAttributesToRender (w);
w.AddAttribute (HtmlTextWriterAttribute.Type,
render_type);
w.AddAttribute (HtmlTextWriterAttribute.Name,
NameAttribute);
if (AutoPostBack) {
w.AddAttribute (HtmlTextWriterAttribute.Onclick, Page.GetPostBackClientHyperlink (this, ""));
}
if (Checked) {
w.AddAttribute (HtmlTextWriterAttribute.Checked, "checked");
}
}
#if NET_2_0
[MonoTODO]
protected override void LoadViewState (object savedState)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override object SaveViewState ()
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override void TrackViewState ()
{
throw new NotImplementedException ();
}
#endif
#if NET_2_0
protected internal
#else
protected
#endif
override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
if (Page != null) {
Page.RegisterRequiresPostBack (this);
}
}
void RenderLabel (HtmlTextWriter w)
{
if (Text.Length > 0) {
w.AddAttribute (HtmlTextWriterAttribute.For, ClientID);
w.RenderBeginTag (HtmlTextWriterTag.Label);
w.Write (this.Text);
w.RenderEndTag ();
}
}
#if NET_2_0
protected internal
#else
protected
#endif
override void Render (HtmlTextWriter w)
{
bool control_style = false;
/* Need to apply the styles around the text
* label too
*/
if (ControlStyleCreated) {
ControlStyle.AddAttributesToRender (w, this);
w.RenderBeginTag (HtmlTextWriterTag.Span);
control_style = true;
} else if (Attributes ["style"] != null) {
/* TODO: check if this or the style
* has precendence, or if they should
* be merged (if I can figure out how
* to turn a CssStyleCollection into a
* Style)
*/
CssStyleCollection style = Attributes.CssStyle;
w.AddAttribute (HtmlTextWriterAttribute.Style,
style.BagToString ());
w.RenderBeginTag (HtmlTextWriterTag.Span);
control_style = true;
}
if (TextAlign == TextAlign.Left) {
RenderLabel (w);
base.Render (w);
} else {
base.Render (w);
RenderLabel (w);
}
if (control_style) {
w.RenderEndTag ();
}
}
#if NET_2_0
[MonoTODO]
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void RaisePostDataChangedEvent ()
{
throw new NotImplementedException ();
}
#endif
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
string postedValue = postCollection[postDataKey];
bool postedBool = ((postedValue != null) &&
(postedValue.Length > 0));
if (Checked != postedBool) {
Checked = postedBool;
return (true);
}
return (false);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
OnCheckedChanged (EventArgs.Empty);
}
internal virtual void InternalAddAttributesToRender (HtmlTextWriter w)
{
}
}
}