Rename to VAR.Focus
This commit is contained in:
67
VAR.Focus.Web/Pages/FormUtils.cs
Normal file
67
VAR.Focus.Web/Pages/FormUtils.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
public class FormUtils
|
||||
{
|
||||
public static Control CreateField(string label, Control fieldControl)
|
||||
{
|
||||
Panel pnlRow = new Panel();
|
||||
pnlRow.CssClass = "formRow";
|
||||
|
||||
Panel pnlLabelContainer = new Panel();
|
||||
pnlLabelContainer.CssClass = "formLabel width25pc";
|
||||
pnlRow.Controls.Add(pnlLabelContainer);
|
||||
|
||||
if (string.IsNullOrEmpty(label) == false)
|
||||
{
|
||||
CLabel lblField = new CLabel();
|
||||
lblField.Text = label;
|
||||
pnlLabelContainer.Controls.Add(lblField);
|
||||
}
|
||||
|
||||
Panel pnlFieldContainer = new Panel();
|
||||
pnlFieldContainer.CssClass = "formField width75pc";
|
||||
pnlRow.Controls.Add(pnlFieldContainer);
|
||||
|
||||
pnlFieldContainer.Controls.Add(fieldControl);
|
||||
|
||||
return pnlRow;
|
||||
}
|
||||
|
||||
public static bool Control_IsValid(Control control)
|
||||
{
|
||||
if (control is IValidableControl)
|
||||
{
|
||||
if (((IValidableControl)control).IsValid() == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Controls_AreValid(ControlCollection controls) {
|
||||
bool valid = true;
|
||||
foreach (Control control in controls)
|
||||
{
|
||||
if (Control_IsValid(control))
|
||||
{
|
||||
if (Controls_AreValid(control.Controls) == false)
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user