writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
#if NET_2_0
if (ValidationGroup != String.Empty)
- writer.AddAttribute ("validationgroup", ValidationGroup);
-#endif
+ 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
#else
validators = Page.Validators;
#endif
- if (validators.Count == 0) {
- return;
- }
// We have validators
errors = new ArrayList(validators.Count);
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))