//
//
-using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
-using System.Web;
-using System.Web.UI;
-using System.Web.UI.WebControls;
+using System.Security.Permissions;
namespace System.Web.UI.WebControls {
+
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
#if NET_2_0
[Designer ("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
#endif
#if NET_2_0
[DefaultValue ("")]
[Themeable (false)]
- public string ValidationGroup
+ public virtual string ValidationGroup
{
get {
return ViewState.GetString("ValidationGroup", string.Empty);
#endregion // Public Instance Properties
#region Public Instance Methods
+ [MonoTODO ()]
+ // for 2.0: not XHTML attributes must be registered with RegisterExpandoAttribute
+ // when it will be implemented, in this case WebUIValidation_2.0.js muist be refactored
protected override void AddAttributesToRender(HtmlTextWriter writer) {
base.AddAttributesToRender (writer);
+#if NET_2_0
+ if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel (ValidationGroup)) {
+#else
if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel ()) {
+#endif
/* force an ID here if we weren't assigned one */
if (ID == null)
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
+#if NET_2_0
+ if (ValidationGroup != String.Empty)
+ RegisterExpandoAttribute (ClientID, "validationGroup", ValidationGroup);
+
+ if (HeaderText.Length > 0)
+ RegisterExpandoAttribute (ClientID, "headertext", HeaderText);
+
+ if (ShowMessageBox)
+ RegisterExpandoAttribute (ClientID, "showmessagebox", "True");
+ if (!ShowSummary)
+ RegisterExpandoAttribute (ClientID, "showsummary", "False");
+
+ if (DisplayMode != ValidationSummaryDisplayMode.BulletList)
+ RegisterExpandoAttribute (ClientID, "displaymode", DisplayMode.ToString ());
+#else
if (HeaderText != "")
writer.AddAttribute ("headertext", HeaderText);
if (DisplayMode != ValidationSummaryDisplayMode.BulletList)
writer.AddAttribute ("displaymode", DisplayMode.ToString());
+#endif
if (!has_errors)
writer.AddStyleAttribute ("display", "none");
}
}
+#if NET_2_0
+ internal void RegisterExpandoAttribute (string controlId, string attributeName, string attributeValue) {
+ RegisterExpandoAttribute (controlId, attributeName, attributeValue, false);
+ }
+
+ internal void RegisterExpandoAttribute (string controlId, string attributeName, string attributeValue, bool encode) {
+ if (Page.ScriptManager != null)
+ Page.ScriptManager.RegisterExpandoAttributeExternal (this, controlId, attributeName, attributeValue, encode);
+ else
+ Page.ClientScript.RegisterExpandoAttribute (controlId, attributeName, attributeValue, encode);
+ }
+#endif
+
#if NET_2_0
protected internal
#else
protected
#endif
override void Render(HtmlTextWriter writer) {
+#if NET_2_0
+ if (!Enabled)
+ return;
+#endif
ValidatorCollection validators;
ArrayList errors;
#else
validators = Page.Validators;
#endif
- if (validators.Count == 0) {
- return;
- }
// We have validators
errors = new ArrayList(validators.Count);
has_errors = errors.Count > 0;
+#if NET_2_0
+ if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel (ValidationGroup)) {
+#else
if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel ()) {
+#endif
+#if NET_2_0
+ if (Page.ScriptManager != null) {
+ Page.ScriptManager.RegisterArrayDeclarationExternal (this, "Page_ValidationSummaries", String.Concat ("document.getElementById ('", ClientID, "')"));
+ Page.ScriptManager.RegisterStartupScriptExternal (this, typeof (BaseValidator), ClientID + "DisposeScript",
+@"
+document.getElementById('" + ClientID + @"').dispose = function() {
+ Array.remove(Page_ValidationSummaries, document.getElementById('" + ClientID + @"'));
+}
+", true);
+ }
+ else
+#endif
Page.ClientScript.RegisterArrayDeclaration ("Page_ValidationSummaries",
- String.Format ("document.getElementById ('{0}')", ClientID));
+ String.Concat ("document.getElementById ('", ClientID, "')"));
}
if ((ShowSummary && has_errors) || (EnableClientScript && pre_render_called))