// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2010 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
using System.Collections.Specialized;
using System.Security.Permissions;
-namespace System.Web.UI.HtmlControls {
-
+namespace System.Web.UI.HtmlControls
+{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("ServerChange")]
-#if NET_2_0
[SupportsEventValidation]
-#endif
- public class HtmlInputRadioButton : HtmlInputControl, IPostBackDataHandler {
-
- private static readonly object serverChangeEvent = new object ();
-
+ public class HtmlInputRadioButton : HtmlInputControl, IPostBackDataHandler
+ {
+ static readonly object serverChangeEvent = new object ();
public HtmlInputRadioButton ()
: base ("radio")
{
}
-
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
}
}
-
-#if NET_2_0
- protected internal
-#else
- protected
-#endif
- override void OnPreRender (EventArgs e)
+ protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
- if (Page != null) {
- Page.RegisterRequiresPostBack (this);
+ Page page = Page;
+ if (page != null && !Disabled) {
+ page.RegisterRequiresPostBack (this);
+ page.RegisterEnabledControl (this);
}
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
- writer.WriteAttribute ("value", Value);
+ Page page = Page;
+ if (page != null)
+ page.ClientScript.RegisterForEventValidation (this.UniqueID, Value);
+ writer.WriteAttribute ("value", Value, true);
Attributes.Remove ("value");
base.RenderAttributes (writer);
}
-#if NET_2_0
+
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
- return DefaultLoadPostData (postDataKey, postCollection);
+ bool checkedOnClient = postCollection [Name] == Value;
+ if (Checked == checkedOnClient)
+ return false;
+
+ ValidateEvent (UniqueID, Value);
+ Checked = checkedOnClient;
+ return checkedOnClient;
}
protected virtual void RaisePostDataChangedEvent ()
{
OnServerChange (EventArgs.Empty);
}
-#endif
-
- internal bool DefaultLoadPostData (string postDataKey, NameValueCollection postCollection)
- {
- string s = postCollection [postDataKey];
- if ((s != null) && (Attributes ["value"] != postDataKey)) {
- Attributes ["value"] = postDataKey;
- // this doesn't seems to trigger a change
- }
- return false;
- }
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
-#if NET_2_0
return LoadPostData (postDataKey, postCollection);
-#else
- return DefaultLoadPostData (postDataKey, postCollection);
-#endif
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
-#if NET_2_0
RaisePostDataChangedEvent ();
-#else
- OnServerChange (EventArgs.Empty);
-#endif
}