Author: mhabersack
Date: 2006-11-17 13:56:07 -0500 (Fri, 17 Nov 2006)
New Revision: 68082
Added:
trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs
Modified:
trunk/mcs/class/System.Web/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputSubmit.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
trunk/mcs/class/System.Web/System.Web.UI/Page.cs
trunk/mcs/class/System.Web/System.Web.UI/PostBackOptions.cs
trunk/mcs/class/System.Web/System.Web.dll.sources
Log:
Support for event validation
Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog 2006-11-17 18:51:50 UTC (rev
68081)
+++ trunk/mcs/class/System.Web/ChangeLog 2006-11-17 18:56:07 UTC (rev
68082)
@@ -2,7 +2,8 @@
* System.Web.dll.sources: Added
System.Web.Compilation/ForceCopyBuildProvider.cs and
- System.Web.Compilation/MasterPageBuildProvider.cs
+ System.Web.Compilation/MasterPageBuildProvider.cs and
+ System.Web.UI/PageLifeCycle.cs
2006-11-09 Vladimir Krasnov <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2006-11-17 18:51:50 UTC
(rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2006-11-17 18:56:07 UTC
(rev 68082)
@@ -1,3 +1,31 @@
+2006-11-17 Marek Habersack <[EMAIL PROTECTED]>
+
+ * PostBackOptions.cs: Renamed the constructors parameters to match
+ those Microsoft .NET uses.
+ targetControl must not be passed null to the constructor.
+
+ * ClientScriptManager.cs: Support for event validation.
+ Implemented a GetPostBackHyperlink overload.
+ Implemented the RegisterForEventValidation methods.
+ Implemented the ValidateEvent method.
+ Added support for saving/restoring event validation state.
+
+ * Page.cs: EnableEventValidation can be set only from the config
+ files (the <pages> element), the Page directive or from
+ Page_Init. After Page_Init returns, an exception is thrown.
+ Made GetFormatter internal, so that ClientScriptManager can use
+ it.
+ Added the internal LifeCycle property which contains the current
+ life cycle stage of the page request processing.
+ Added calls to save/restore event validation state.
+ Added checks for whether child controls of the page support event
+ validation or not.
+ Added calls to ClientScriptManager.ValidateEvent in appropriate
+ places.
+
+ * PageLifeCycle.cs: Added the PageLifeCycle enum, used in event
+ validation.
+
2006-11-16 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* LosFormatter.cs:
Modified: trunk/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -34,6 +34,9 @@
using System;
using System.Collections;
+#if NET_2_0
+using System.Collections.Generic;
+#endif
using System.Text;
namespace System.Web.UI
@@ -52,7 +55,10 @@
ScriptEntry submitStatements;
ScriptEntry scriptIncludes;
Page page;
-
+#if NET_2_0
+ List <int> eventValidationValues;
+#endif
+
internal ClientScriptManager (Page page)
{
this.page = page;
@@ -70,6 +76,15 @@
return "javascript:" + GetPostBackEventReference
(control, argument);
}
+#if NET_2_0
+ public string GetPostBackClientHyperlink (Control control,
string argument, bool registerForEventValidation)
+ {
+ if (registerForEventValidation)
+ RegisterForEventValidation (control.UniqueID,
argument);
+ return "javascript:" + GetPostBackEventReference
(control, argument);
+ }
+#endif
+
public string GetPostBackEventReference (Control control,
string argument)
{
page.RequiresPostBackScript ();
@@ -339,35 +354,64 @@
{
throw new NotImplementedException ();
}
-
- [MonoTODO]
+
+ // Implemented following the description in
http://odetocode.com/Blogs/scott/archive/2006/03/20/3145.aspx
+ private int CalculateEventHash (string uniqueId, string
argument)
+ {
+ int uniqueIdHash = uniqueId.GetHashCode ();
+ int argumentHash = (argument == null) ? 0 :
argument.GetHashCode ();
+ return (uniqueIdHash ^ argumentHash);
+ }
+
public void RegisterForEventValidation (PostBackOptions options)
{
- throw new NotImplementedException ();
+ // MS.NET does not check for options == null, so we
won't too...
+ RegisterForEventValidation
(options.TargetControl.UniqueID, options.Argument);
}
- [MonoTODO]
public void RegisterForEventValidation (string uniqueId)
{
- throw new NotImplementedException ();
+ RegisterForEventValidation (uniqueId, null);
}
-
- [MonoTODO]
+
public void RegisterForEventValidation (string uniqueId, string
argument)
{
- throw new NotImplementedException ();
+ if (!page.EnableEventValidation)
+ return;
+ if (uniqueId == null || uniqueId.Length == 0)
+ return;
+ if (page.LifeCycle < PageLifeCycle.Render)
+ throw new InvalidOperationException
("RegisterForEventValidation may only be called from the Render method");
+ if (eventValidationValues == null)
+ eventValidationValues = new List <int> ();
+
+
+ int hash = CalculateEventHash (uniqueId, argument);
+ if (eventValidationValues.BinarySearch (hash) < 0)
+ eventValidationValues.Add (hash);
}
- [MonoTODO]
public void ValidateEvent (string uniqueId)
{
- throw new NotImplementedException ();
+ ValidateEvent (uniqueId, null);
}
- [MonoTODO]
public void ValidateEvent (string uniqueId, string argument)
{
- throw new NotImplementedException ();
+ if (uniqueId == null || uniqueId.Length == 0)
+ throw new ArgumentException ("must not be null
or empty", "uniqueId");
+ if (!page.EnableEventValidation)
+ return;
+ if (eventValidationValues == null)
+ goto bad;
+
+ int hash = CalculateEventHash (uniqueId, argument);
+ if (eventValidationValues.BinarySearch (hash) < 0)
+ goto bad;
+ return;
+
+ bad:
+ throw new ArgumentException ("Invalid postback or
callback argument. Event validation is enabled using <pages
enableEventValidation=\"true\"/> in configuration or <%@ Page
EnableEventValidation=\"true\" %> in a page. For security purposes, this
feature verifies that arguments to postback or callback events originate from
the server control that originally rendered them. If the data is valid and
expected, use the ClientScriptManager.RegisterForEventValidation method in
order to register the postback or callback data for validation.");
}
#endif
void WriteScripts (HtmlTextWriter writer, ScriptEntry
scriptList)
@@ -377,7 +421,31 @@
scriptList = scriptList.Next;
}
}
+
+#if NET_2_0
+ internal void RestoreEventValidationState (string fieldValue)
+ {
+ if (!page.EnableEventValidation || fieldValue == null
|| fieldValue.Length == 0)
+ return;
+ LosFormatter fmt = page.GetFormatter ();
+ eventValidationValues = (List <int>)fmt.Deserialize
(fieldValue);
+ }
+ internal void SaveEventValidationState ()
+ {
+ if (!page.EnableEventValidation ||
eventValidationValues == null || eventValidationValues.Count == 0)
+ return;
+ eventValidationValues.Sort ();
+ LosFormatter fmt = page.GetFormatter ();
+ RegisterHiddenField (EventStateFieldName,
fmt.SerializeToBase64 (eventValidationValues));
+ }
+
+ internal string EventStateFieldName
+ {
+ get { return "__EVENTVALIDATION"; }
+ }
+#endif
+
internal void WriteHiddenFields (HtmlTextWriter writer)
{
if (hiddenFields == null)
Modified: trunk/mcs/class/System.Web/System.Web.UI/Page.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/Page.cs 2006-11-17 18:51:50 UTC
(rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI/Page.cs 2006-11-17 18:56:07 UTC
(rev 68082)
@@ -71,6 +71,7 @@
public class Page : TemplateControl, IHttpHandler
{
#if NET_2_0
+ private PageLifeCycle _lifeCycle = PageLifeCycle.Unknown;
private bool _eventValidation = true;
#endif
private bool _viewState = true;
@@ -281,8 +282,16 @@
#if NET_2_0
public virtual bool EnableEventValidation {
get { return _eventValidation; }
- set { _eventValidation = value;}
+ set {
+ if (_lifeCycle > PageLifeCycle.Init)
+ throw new InvalidOperationException ("The
'EnableEventValidation' property can be set only in the Page_init, the Page
directive or in the <pages> configuration section.");
+ _eventValidation = value;
+ }
}
+
+ internal PageLifeCycle LifeCycle {
+ get { return _lifeCycle; }
+ }
#endif
[Browsable (false)]
@@ -942,7 +951,7 @@
scriptManager.WriteClientScriptBlocks (writer);
}
- LosFormatter GetFormatter ()
+ internal LosFormatter GetFormatter ()
{
#if NET_2_0
PagesSection config = (PagesSection)
WebConfigurationManager.GetSection ("system.web/pages");
@@ -983,7 +992,10 @@
if (!postBackScriptRendered && requiresPostBackScript)
RenderPostBackScript (writer, formUniqueID);
-
+
+#if NET_2_0
+ scriptManager.SaveEventValidationState ();
+#endif
scriptManager.WriteHiddenFields (writer);
scriptManager.WriteClientScriptIncludes (writer);
scriptManager.WriteStartupScriptBlocks (writer);
@@ -1069,6 +1081,9 @@
public void ProcessRequest (HttpContext context)
#endif
{
+#if NET_2_0
+ _lifeCycle = PageLifeCycle.Unknown;
+#endif
_context = context;
if (clientTarget != null)
Request.ClientTarget = clientTarget;
@@ -1096,8 +1111,14 @@
throw;
} finally {
try {
+#if NET_2_0
+ _lifeCycle = PageLifeCycle.Unload;
+#endif
RenderTrace ();
UnloadRecursive (true);
+#if NET_2_0
+ _lifeCycle = PageLifeCycle.End;
+#endif
} catch {}
if (Thread.CurrentThread.CurrentCulture.Equals
(culture) == false)
Thread.CurrentThread.CurrentCulture = culture;
@@ -1120,6 +1141,7 @@
_requestValueCollection = this.DeterminePostBackMode();
#if NET_2_0
+ _lifeCycle = PageLifeCycle.Start;
// http://msdn2.microsoft.com/en-us/library/ms178141.aspx
if (_requestValueCollection != null) {
if (!isCrossPagePostBack && _requestValueCollection
[PreviousPageID] != null && _requestValueCollection [PreviousPageID] !=
Request.FilePath) {
@@ -1131,22 +1153,28 @@
}
}
+ _lifeCycle = PageLifeCycle.PreInit;
OnPreInit (EventArgs.Empty);
InitializeTheme ();
ApplyMasterPage ();
+ _lifeCycle = PageLifeCycle.Init;
#endif
Trace.Write ("aspx.page", "Begin Init");
InitRecursive (null);
Trace.Write ("aspx.page", "End Init");
#if NET_2_0
+ _lifeCycle = PageLifeCycle.InitComplete;
OnInitComplete (EventArgs.Empty);
#endif
renderingForm = false;
#if NET_2_0
if (IsPostBack || IsCallback) {
+ _lifeCycle = PageLifeCycle.PreLoad;
+ if (_requestValueCollection != null)
+ scriptManager.RestoreEventValidationState
(_requestValueCollection [scriptManager.EventStateFieldName]);
#else
if (IsPostBack) {
#endif
@@ -1160,11 +1188,13 @@
#if NET_2_0
OnPreLoad (EventArgs.Empty);
+ _lifeCycle = PageLifeCycle.Load;
#endif
LoadRecursive ();
#if NET_2_0
if (IsPostBack || IsCallback) {
+ _lifeCycle = PageLifeCycle.ControlEvents;
#else
if (IsPostBack) {
#endif
@@ -1180,6 +1210,7 @@
}
#if NET_2_0
+ _lifeCycle = PageLifeCycle.LoadComplete;
OnLoadComplete (EventArgs.Empty);
if (IsCrossPagePostBack)
@@ -1192,6 +1223,8 @@
callbackOutput.Flush ();
return;
}
+
+ _lifeCycle = PageLifeCycle.PreRender;
#endif
Trace.Write ("aspx.page", "Begin PreRender");
@@ -1207,7 +1240,9 @@
Trace.Write ("aspx.page", "End SaveViewState");
#if NET_2_0
+ _lifeCycle = PageLifeCycle.SaveStateComplete;
OnSaveStateComplete (EventArgs.Empty);
+ _lifeCycle = PageLifeCycle.Render;
#endif
//--
@@ -1235,9 +1270,31 @@
}
}
+#if NET_2_0
+ bool CheckForValidationSupport (Control targetControl)
+ {
+ if (targetControl == null)
+ return false;
+ Type type = targetControl.GetType ();
+ object[] attributes = type.GetCustomAttributes (true);
+ foreach (object attr in attributes)
+ if (attr is SupportsEventValidationAttribute)
+ return true;
+ return false;
+ }
+#endif
+
void RaisePostBackEvents ()
{
+#if NET_2_0
+ Control targetControl;
+#endif
if (requiresRaiseEvent != null) {
+#if NET_2_0
+ targetControl = requiresRaiseEvent as Control;
+ if (targetControl != null && CheckForValidationSupport
(targetControl))
+ scriptManager.ValidateEvent
(targetControl.UniqueID, null);
+#endif
RaisePostBackEvent (requiresRaiseEvent, null);
return;
}
@@ -1252,11 +1309,21 @@
return;
}
+#if NET_2_0
+ targetControl = FindControl (eventTarget);
+ IPostBackEventHandler target = targetControl as
IPostBackEventHandler;
+#else
IPostBackEventHandler target = FindControl (eventTarget) as
IPostBackEventHandler;
+#endif
+
if (target == null)
return;
string eventArgument = postdata [postEventArgumentID];
+#if NET_2_0
+ if (CheckForValidationSupport (targetControl))
+ scriptManager.ValidateEvent (targetControl.UniqueID,
eventArgument);
+#endif
RaisePostBackEvent (target, eventArgument);
}
@@ -1675,11 +1742,14 @@
if (callbackTarget == null || callbackTarget.Length == 0)
throw new HttpException ("Callback target not
provided.");
- ICallbackEventHandler target = FindControl (callbackTarget) as
ICallbackEventHandler;
+ Control targetControl = FindControl (callbackTarget);
+ ICallbackEventHandler target = targetControl as
ICallbackEventHandler;
if (target == null)
throw new HttpException (string.Format ("Invalid
callback target '{0}'.", callbackTarget));
string callbackArgument = _requestValueCollection
[CallbackArgumentID];
+ if (CheckForValidationSupport (targetControl))
+ scriptManager.ValidateEvent (targetControl.UniqueID,
callbackArgument);
target.RaiseCallbackEvent (callbackArgument);
return target.GetCallbackResult ();
}
Added: trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs 2006-11-17
18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI/PageLifeCycle.cs 2006-11-17
18:56:07 UTC (rev 68082)
@@ -0,0 +1,48 @@
+//
+// System.Web.Compilation.PageLifeCycle
+//
+// Authors:
+// Marek Habersack ([EMAIL PROTECTED])
+//
+// (C) 2006 Marek Habersack
+//
+
+//
+// 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.
+//
+#if NET_2_0
+internal enum PageLifeCycle
+{
+ Unknown = 1,
+ Start,
+ PreInit,
+ Init,
+ InitComplete,
+ PreLoad,
+ Load,
+ ControlEvents,
+ LoadComplete,
+ PreRender,
+ SaveStateComplete,
+ Render,
+ Unload,
+ End
+}
+#endif
Modified: trunk/mcs/class/System.Web/System.Web.UI/PostBackOptions.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/PostBackOptions.cs 2006-11-17
18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI/PostBackOptions.cs 2006-11-17
18:56:07 UTC (rev 68082)
@@ -45,29 +45,31 @@
private bool performValidation;
private string validationGroup;
- public PostBackOptions (Control control)
- : this (control, null, null, false, false, false, true,
false, null)
+ public PostBackOptions (Control targetControl)
+ : this (targetControl, null, null, false, false, false,
true, false, null)
{
}
- public PostBackOptions (Control control, string argument)
- : this (control, argument, null, false, false, false,
true, false, null)
+ public PostBackOptions (Control targetControl, string argument)
+ : this (targetControl, argument, null, false, false,
false, true, false, null)
{
}
- public PostBackOptions (Control control, string argument,
string actionUrl, bool isAutoPostBack,
- bool isJavaScriptProtocolRequired, bool
isTrackFocus, bool isClientSubmit,
- bool isValidationPerformed, string
validatingGroup)
+ public PostBackOptions (Control targetControl, string argument,
string actionUrl, bool autoPostBack,
+ bool requiresJavaScriptProtocol, bool
trackFocus, bool clientSubmit,
+ bool performValidation, string
validationGroup)
{
- this.control = control;
+ if (targetControl == null)
+ throw new ArgumentNullException
("targetControl");
+ this.control = targetControl;
this.argument = argument;
this.actionUrl = actionUrl;
- this.autoPostBack = isAutoPostBack;
- this.requiresJavaScriptProtocol =
isJavaScriptProtocolRequired;
- this.trackFocus = isTrackFocus;
- this.clientSubmit = isClientSubmit;
- this.performValidation = isValidationPerformed;
- this.validationGroup = validatingGroup;
+ this.autoPostBack = autoPostBack;
+ this.requiresJavaScriptProtocol =
requiresJavaScriptProtocol;
+ this.trackFocus = trackFocus;
+ this.clientSubmit = clientSubmit;
+ this.performValidation = performValidation;
+ this.validationGroup = validationGroup;
}
[DefaultValue ("")]
Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
2006-11-17 18:56:07 UTC (rev 68082)
@@ -1,3 +1,23 @@
+2006-11-17 Marek Habersack <[EMAIL PROTECTED]>
+
+ * HtmlInputHidden.cs: Added support for event validation.
+
+ * HtmlInputCheckBox.cs: Added support for event validation.
+
+ * HtmlInputImage.cs: Added support for event validation.
+
+ * HtmlInputButton.cs: Added support for event validation.
+
+ * HtmlSelect.cs: Added support for event validation.
+
+ * HtmlTextArea.cs: Added support for event validation.
+
+ * HtmlButton.cs: Added support for event validation.
+
+ * HtmlInputRadioButton.cs: Added support for event validation.
+
+ * HtmlInputText.cs: Added support for event validation.
+
2006-11-13 Igor Zelmanovich <[EMAIL PROTECTED]>
* HtmlContainerControl.cs: fixed: InnerHtml property
Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -97,7 +97,7 @@
#endif
OnServerClick (EventArgs.Empty);
}
-
+
#if NET_2_0
protected internal
#else
@@ -121,6 +121,7 @@
#if NET_2_0
if (Page != null && Events [ServerClickEvent] != null) {
PostBackOptions options = GetPostBackOptions ();
+ Page.ClientScript.RegisterForEventValidation
(options);
Attributes ["onclick"] +=
Page.ClientScript.GetPostBackEventReference (options);
writer.WriteAttribute ("language",
"javascript");
}
Modified:
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -177,6 +177,7 @@
}
if (Page != null) {
PostBackOptions options =
GetPostBackOptions ();
+
Page.ClientScript.RegisterForEventValidation (options);
onclick +=
Page.ClientScript.GetPostBackEventReference (options);
}
Modified:
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -88,6 +88,15 @@
}
#if NET_2_0
+ protected override void RenderAttributes (HtmlTextWriter writer)
+ {
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+ base.RenderAttributes (writer);
+ }
+#endif
+
+#if NET_2_0
protected internal
#else
protected
Modified:
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -95,6 +95,13 @@
}
#if NET_2_0
+ protected override void RenderAttributes (HtmlTextWriter writer)
+ {
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+ base.RenderAttributes (writer);
+ }
+
protected internal
#else
protected
Modified:
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -246,6 +246,9 @@
protected override void RenderAttributes (HtmlTextWriter writer)
{
#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+
if (CausesValidation && Page != null &&
Page.AreValidatorsUplevel (ValidationGroup)) {
ClientScriptManager csm = Page.ClientScript;
Attributes ["onclick"] +=
csm.GetClientValidationEvent (ValidationGroup);
Modified:
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -96,7 +96,6 @@
}
}
-
#if NET_2_0
protected internal
#else
@@ -120,6 +119,10 @@
protected override void RenderAttributes (HtmlTextWriter writer)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID, Value);
+#endif
writer.WriteAttribute ("value", Value);
Attributes.Remove ("value");
base.RenderAttributes (writer);
Modified:
trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputSubmit.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputSubmit.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputSubmit.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -50,7 +50,7 @@
: base (type)
{
}
-
+
[MonoTODO ("why our own version?")]
void IPostBackEventHandler.RaisePostBackEvent (string
eventArgument)
{
Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -111,6 +111,14 @@
#if NET_2_0
+ protected internal override void Render (HtmlTextWriter writer)
+ {
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+ base.Render (writer);
+ }
+#endif
+
+#if NET_2_0
protected internal
#else
protected
Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -611,6 +611,10 @@
protected override void RenderAttributes (HtmlTextWriter w)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+#endif
/* If there is no "name" attribute,
* LoadPostData doesn't work...
*/
@@ -645,7 +649,6 @@
int count = items.Count;
for (int i = 0; i < count; i++) {
ListItem item = items[i];
-
w.Indent++;
/* Write the <option> elements this
Modified: trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -137,6 +137,10 @@
protected override void RenderAttributes (HtmlTextWriter writer)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+#endif
if (Attributes ["name"] == null) {
writer.WriteAttribute ("name", Name);
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -172,7 +172,14 @@
protected internal override void RenderContents (HtmlTextWriter
writer)
{
int idx = 0;
+#if NET_2_0
+ bool havePage = Page != null;
+#endif
foreach (ListItem i in Items) {
+#if NET_2_0
+ if (havePage)
+
Page.ClientScript.RegisterForEventValidation (this.UniqueID, i.Value.ToString
());
+#endif
writer.RenderBeginTag (HtmlTextWriterTag.Li);
this.RenderBulletText (i, idx ++, writer);
writer.RenderEndTag ();
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -164,9 +164,13 @@
#endif
protected override void AddAttributesToRender (HtmlTextWriter
writer) {
- if (Page != null)
+ if (Page != null) {
+#if NET_2_0
+ Page.ClientScript.RegisterForEventValidation
(GetPostBackOptions ());
+#endif
Page.VerifyRenderingInServerForm (this);
-
+ }
+
#if NET_2_0
writer.AddAttribute (HtmlTextWriterAttribute.Type,
UseSubmitBehavior ? "submit" : "button");
writer.AddAttribute (HtmlTextWriterAttribute.Name,
UniqueID);
@@ -270,14 +274,14 @@
protected internal
#else
protected
-#endif
+#endif
override void RenderContents (HtmlTextWriter writer)
- {
- }
-
+ {
+ }
+
[WebSysDescription ("")]
[WebCategory ("Action")]
- public event EventHandler Click
+ public event EventHandler Click
{
add {
Events.AddHandler (ClickEvent, value);
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -786,6 +786,10 @@
#endif
override void Render (HtmlTextWriter writer)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+#endif
Table table = new Table ();
table.CellSpacing = CellSpacing;
table.CellPadding = CellPadding;
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2006-11-17 18:56:07 UTC (rev 68082)
@@ -1,3 +1,25 @@
+2006-11-17 Marek Habersack <[EMAIL PROTECTED]>
+
+ * ImageButton.cs: Added support for event validation.
+
+ * ListBox.cs: Added support for event validation.
+
+ * Calendar.cs: Added support for event validation.
+
+ * DropDownList.cs: Added support for event validation.
+
+ * FormView.cs: Added support for event validation.
+
+ * RadioButtonList.cs: Added support for event validation.
+
+ * TextBox.cs: Added support for event validation.
+
+ * BulletedList.cs: Added support for event validation.
+
+ * CheckBox.cs: Added support for event validation.
+
+ * Button.cs: Added support for event validation.
+
2006-11-16 Igor Zelmanovich <[EMAIL PROTECTED]>
* CreateUserWizard.cs: fixed: ActiveStepIndex property.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -362,9 +362,13 @@
#endif
override void Render (HtmlTextWriter w)
{
- if (Page != null)
+ if (Page != null) {
+#if NET_2_0
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+#endif
Page.VerifyRenderingInServerForm (this);
-
+ }
+
bool need_span = ControlStyleCreated &&
!ControlStyle.IsEmpty;
if (need_span)
ControlStyle.AddAttributesToRender (w, this);
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -180,7 +180,9 @@
for (int i = 0; i < count; i++) {
item = Items[i];
-
+#if NET_2_0
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID, item.Value.ToString ());
+#endif
writer.WriteBeginTag("option");
if (item.Selected) {
if (selected) {
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -1464,6 +1464,10 @@
protected internal override void Render (HtmlTextWriter writer)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+#endif
PrepareControlHierarchy ();
if (table == null)
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -209,9 +209,13 @@
protected override void AddAttributesToRender (HtmlTextWriter
writer)
{
- if (Page != null)
+ if (Page != null) {
+#if NET_2_0
+ Page.ClientScript.RegisterForEventValidation
(GetPostBackOptions ());
+#endif
Page.VerifyRenderingInServerForm (this);
-
+ }
+
writer.AddAttribute (HtmlTextWriterAttribute.Type,
"image");
writer.AddAttribute (HtmlTextWriterAttribute.Name,
UniqueID);
#if NET_2_0
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -183,7 +183,14 @@
#endif
override void RenderContents (HtmlTextWriter writer)
{
+#if NET_2_0
+ bool havePage = Page != null;
+#endif
foreach (ListItem item in Items) {
+#if NET_2_0
+ if (havePage)
+
Page.ClientScript.RegisterForEventValidation (this.UniqueID,
item.Value.ToString ());
+#endif
writer.WriteBeginTag ("option");
if (item.Selected) {
writer.WriteAttribute ("selected",
"selected", false);
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -339,6 +339,9 @@
override void Render (HtmlTextWriter writer)
{
#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+
if (Items.Count == 0)
return;
#endif
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
2006-11-17 18:51:50 UTC (rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
2006-11-17 18:56:07 UTC (rev 68082)
@@ -140,6 +140,10 @@
#endif
override void Render (HtmlTextWriter w)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation
(this.UniqueID);
+#endif
// Why didn't msft just override RenderContents!?
RenderBeginTag (w);
if (TextMode == TextBoxMode.MultiLine)
Modified: trunk/mcs/class/System.Web/System.Web.dll.sources
===================================================================
--- trunk/mcs/class/System.Web/System.Web.dll.sources 2006-11-17 18:51:50 UTC
(rev 68081)
+++ trunk/mcs/class/System.Web/System.Web.dll.sources 2006-11-17 18:56:07 UTC
(rev 68082)
@@ -589,6 +589,7 @@
System.Web.UI/OutputCacheParameters.cs
System.Web.UI/Page.cs
System.Web.UI/PageHandlerFactory.cs
+System.Web.UI/PageLifeCycle.cs
System.Web.UI/PageParser.cs
System.Web.UI/PageStatePersister.cs
System.Web.UI/PageTheme.cs
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches