Fixes up validation styling and the validation summary close button display.

This commit is contained in:
Shannon
2013-07-24 11:31:31 +10:00
parent 8b2d1b8eab
commit 7164f23a98
2 changed files with 23 additions and 16 deletions

View File

@@ -545,16 +545,19 @@ namespace umbraco.controls
{
try
{
RequiredFieldValidator rq = new RequiredFieldValidator();
rq.ControlToValidate = dt.DataEditor.Editor.ID;
Control component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate);
ValidationPropertyAttribute attribute =
(ValidationPropertyAttribute)
TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)];
var rq = new RequiredFieldValidator
{
ControlToValidate = dt.DataEditor.Editor.ID,
CssClass = "error"
};
rq.Style.Add(HtmlTextWriterStyle.Display, "block");
rq.Style.Add(HtmlTextWriterStyle.Padding, "2px");
var component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate);
var attribute = (ValidationPropertyAttribute)TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)];
PropertyDescriptor pd = null;
if (attribute != null)
{
pd = TypeDescriptor.GetProperties(component, (Attribute[])null)[attribute.Name];
pd = TypeDescriptor.GetProperties(component, null)[attribute.Name];
}
if (pd != null)
{
@@ -578,17 +581,19 @@ namespace umbraco.controls
{
try
{
RegularExpressionValidator rv = new RegularExpressionValidator();
rv.ControlToValidate = dt.DataEditor.Editor.ID;
Control component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate);
ValidationPropertyAttribute attribute =
(ValidationPropertyAttribute)
TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)];
var rv = new RegularExpressionValidator
{
ControlToValidate = dt.DataEditor.Editor.ID,
CssClass = "error"
};
rv.Style.Add(HtmlTextWriterStyle.Display, "block");
rv.Style.Add(HtmlTextWriterStyle.Padding, "2px");
var component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate);
var attribute = (ValidationPropertyAttribute)TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)];
PropertyDescriptor pd = null;
if (attribute != null)
{
pd = TypeDescriptor.GetProperties(component, (Attribute[])null)[attribute.Name];
pd = TypeDescriptor.GetProperties(component, null)[attribute.Name];
}
if (pd != null)
{

View File

@@ -18,6 +18,7 @@ namespace umbraco.uicontrols {
private bool _hasMenu = true;
private readonly ScrollingMenu _menu = new ScrollingMenu();
protected LiteralControl ErrorHeaderControl = new LiteralControl();
private LiteralControl _closeButtonControl = new LiteralControl();
private readonly ValidationSummary _vs = new ValidationSummary();
private readonly Control _tempErr = new Control();
@@ -61,7 +62,7 @@ namespace umbraco.uicontrols {
// Add error pane
_tempErr.Visible = false;
_tempErr.ID = String.Format("{0}_errorPaneContainer", this.ID);
_tempErr.Controls.Add(new LiteralControl("<div id=\"errorPane_" + this.ClientID + "\" style='margin: 10px 0px 10px 0px; text-align: left;' class=\"error\"><div style=\"float: right; padding: 5px;\"><a href=\"#\" onClick=\"javascript:document.getElementById('errorPane_" + this.ClientID + "').style.display = 'none'; return false;\">" + CloseCaption + "</a></div><h3>"));
_tempErr.Controls.Add(_closeButtonControl);
_tempErr.Controls.Add(ErrorHeaderControl);
_tempErr.Controls.Add(new LiteralControl("</h3><p>"));
_tempErr.Controls.Add(_vs);
@@ -84,6 +85,7 @@ namespace umbraco.uicontrols {
protected override void Render(HtmlTextWriter writer)
{
_closeButtonControl.Text = "<div id=\"errorPane_" + this.ClientID + "\" style='margin: 10px 0px 10px 0px; text-align: left;' class=\"error\"><div style=\"float: right; padding: 5px;\"><a href=\"#\" onClick=\"javascript:document.getElementById('errorPane_" + this.ClientID + "').style.display = 'none'; return false;\">" + CloseCaption + "</a></div><h3>";
ErrorHeaderControl.Text = ErrorHeader;
CreateChildControls();
writer.WriteLine("<div id='" + this.ClientID + "' class='tabpage'>");