| |||||||||||||||||
| Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
| Web\WebControls\ValidatedControl.cs | - | 85,7 % | 71,4 % | 78,6 % |
|
||||||||||||
| 1 | #region Copyright | |
| 2 | /* | |
| 3 | ShowX. Maps business objects into presentation layer. | |
| 4 | Copyright (C) 2005 Jesus Diaz. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with this library; if not, write to the Free Software | |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | For project details see: http://showx.sourceforge.net | |
| 21 | */ | |
| 22 | #endregion | |
| 23 | ||
| 24 | using System.Collections; | |
| 25 | using System.Web.UI; | |
| 26 | using System.Web.UI.WebControls; | |
| 27 | ||
| 28 | namespace ShowX.Web.WebControls | |
| 29 | { | |
| 30 | /// <summary> | |
| 31 | /// Base class for ShowX web controls that includes custom validation. | |
| 32 | /// </summary> | |
| 33 | public abstract class ValidatedControl : WebControl, INamingContainer | |
| 34 | { | |
| 35 | /// <summary> | |
| 36 | /// Message to show when text don't validate | |
| 37 | /// </summary> | |
| 38 | protected Label messageL; | |
| 39 | ||
| 40 | /// <summary> | |
| 41 | /// Validators associated to this control | |
| 42 | /// </summary> | |
| 43 | protected ArrayList validators; | |
| 44 | ||
| 45 | /// <summary> | |
| 46 | /// Reflex the validator attribute | |
| 47 | /// </summary> | |
| 48 | 169 | public ArrayList Validators { get { return validators; }} |
| 49 | ||
| 50 | /// <summary> | |
| 51 | /// Reflex the message value | |
| 52 | /// </summary> | |
| 53 | 0 | public Label Message { get { return this.messageL; }} |
| 54 | ||
| 55 | /// <summary> | |
| 56 | /// Reflex the state of the control, according to validation | |
| 57 | /// </summary> | |
| 58 | public bool Validated | |
| 59 | { | |
| 60 | 179 | get |
| 61 | { | |
| 62 | 179 | return (ViewState["TextFieldValidated"] == null) ? true : |
| 63 | (bool)ViewState["TextFieldValidated"]; | |
| 64 | } | |
| 65 | ||
| 66 | 43 | set |
| 67 | { | |
| 68 | 43 | ViewState["TextFieldValidated"] = value; |
| 69 | } | |
| 70 | } | |
| 71 | ||
| 72 | /// <summary> | |
| 73 | /// Constructor | |
| 74 | /// </summary> | |
| 75 | 170 | public ValidatedControl() |
| 76 | { | |
| 77 | 170 | Controls.Add(messageL = new Label()); |
| 78 | 170 | validators = new ArrayList(); |
| 79 | } | |
| 80 | ||
| 81 | /// <summary> | |
| 82 | /// Allow to check whether the values entered are valid | |
| 83 | /// </summary> | |
| 84 | /// <returns>True if the input value is te same, false otherwise</returns> | |
| 85 | public abstract bool Validate(object context); | |
| 86 | ||
| 87 | /// <summary> | |
| 88 | /// Set the style to childs | |
| 89 | /// </summary> | |
| 90 | /// <param name="style">Style to apply</param> | |
| 91 | 112 | public virtual void MergeTextStyle(Style style) |
| 92 | { | |
| 93 | 112 | messageL.MergeStyle(style); |
| 94 | } | |
| 95 | ||
| 96 | /// <summary> | |
| 97 | /// Set the style to childs | |
| 98 | /// </summary> | |
| 99 | /// <param name="style">Style to apply</param> | |
| 100 | 0 | public virtual void MergeControlStyle(Style style) {} |
| 101 | ||
| 102 | } | |
| 103 | } | |
| 104 |
|
||||||||