Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / RangeValidator.cs / 1305376 / RangeValidator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Drawing; using System.Web; using System.Web.UI; using System.Web.UI.Design.WebControls; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using WebCntrls = System.Web.UI.WebControls; using System.Security.Permissions; namespace System.Web.UI.MobileControls { /* * Mobile RangeValidator class. * The RangeValidator checks that the value of the associated input control * is within a minimum and maximum value. These can either be constant * values or other input controls. A data type property specifies how the * values being compared should be interpreted: Strings, integers, dates, * etc. * * Copyright (c) 2000 Microsoft Corporation */ ///[ ToolboxData("<{0}:RangeValidator runat=\"server\" ErrorMessage=\"RangeValidator\">{0}:RangeValidator>"), ToolboxItem("System.Web.UI.Design.WebControlToolboxItem, " + AssemblyRef.SystemDesign) ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public class RangeValidator : BaseValidator { private WebCntrls.RangeValidator _webRangeValidator; /// protected override WebCntrls.BaseValidator CreateWebValidator() { _webRangeValidator = new WebCntrls.RangeValidator(); return _webRangeValidator; } //////////////////////////////////////////////////////////////////////// // Mimic the properties exposed in the original RangeValidator. // The properties are got and set directly from the original RangeValidator. //////////////////////////////////////////////////////////////////////// /// [ Bindable(true), DefaultValue(""), MobileCategory(SR.Category_Behavior), MobileSysDescription(SR.RangeValidator_MaximumValue) ] public String MaximumValue { get { return _webRangeValidator.MaximumValue; } set { _webRangeValidator.MaximumValue = value; } } /// [ Bindable(true), DefaultValue(""), MobileCategory(SR.Category_Behavior), MobileSysDescription(SR.RangeValidator_MinimumValue) ] public String MinimumValue { get { return _webRangeValidator.MinimumValue; } set { _webRangeValidator.MinimumValue = value; } } /// [ Bindable(false), DefaultValue(ValidationDataType.String), MobileCategory(SR.Category_Behavior), MobileSysDescription(SR.RangeValidator_Type) ] public ValidationDataType Type { get { return _webRangeValidator.Type; } set { _webRangeValidator.Type = value; } } /// protected override bool EvaluateIsValid() { return EvaluateIsValidInternal(); } ///////////////////////////////////////////////////////////////////// // Helper function adopted from WebForms RangeValidator ///////////////////////////////////////////////////////////////////// /// protected override bool ControlPropertiesValid() { // Check if the control values can be converted to data type String maximumValue = MaximumValue; if (!WebCntrls.BaseCompareValidator.CanConvert(maximumValue, Type)) { throw new ArgumentException(SR.GetString( SR.Validator_ValueBadType, maximumValue, "MaximumValue", ID, PropertyConverter.EnumToString( typeof(ValidationDataType), Type) )); } String minumumValue = MinimumValue; if (!WebCntrls.BaseCompareValidator.CanConvert(minumumValue, Type)) { throw new ArgumentException(SR.GetString( SR.Validator_ValueBadType, minumumValue, "MinimumValue", ID, PropertyConverter.EnumToString( typeof(ValidationDataType), Type) )); } // Check for overlap. if (WebBaseCompareValidator.Compare(minumumValue, maximumValue, ValidationCompareOperator.GreaterThan, Type)) { throw new ArgumentException(SR.GetString( SR.RangeValidator_RangeOverlap, maximumValue, minumumValue, ID)); } return base.ControlPropertiesValid(); } // The reason of having this class is to expose the method // BaseCompareValidator.Compare which is a protected method in the // base class. Since the implementation of the method is not // trivial, instead of copying the code to this file, the following // subclass inherits the base class and expose a new public method // which calls its base implementation. While this solution doesn't // look elegant, it helps eliminate the code maintanence issue of // copying the code. private class WebBaseCompareValidator : BaseCompareValidator { // Have to define this method since it is abstract in the base // class. protected override bool EvaluateIsValid() { Debug.Assert(false, "Should never be called."); return true; } public static new bool Compare( String leftText, String rightText, ValidationCompareOperator op, ValidationDataType type) { return BaseCompareValidator.Compare(leftText, rightText, op, type); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Drawing; using System.Web; using System.Web.UI; using System.Web.UI.Design.WebControls; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using WebCntrls = System.Web.UI.WebControls; using System.Security.Permissions; namespace System.Web.UI.MobileControls { /* * Mobile RangeValidator class. * The RangeValidator checks that the value of the associated input control * is within a minimum and maximum value. These can either be constant * values or other input controls. A data type property specifies how the * values being compared should be interpreted: Strings, integers, dates, * etc. * * Copyright (c) 2000 Microsoft Corporation */ ///[ ToolboxData("<{0}:RangeValidator runat=\"server\" ErrorMessage=\"RangeValidator\">{0}:RangeValidator>"), ToolboxItem("System.Web.UI.Design.WebControlToolboxItem, " + AssemblyRef.SystemDesign) ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public class RangeValidator : BaseValidator { private WebCntrls.RangeValidator _webRangeValidator; /// protected override WebCntrls.BaseValidator CreateWebValidator() { _webRangeValidator = new WebCntrls.RangeValidator(); return _webRangeValidator; } //////////////////////////////////////////////////////////////////////// // Mimic the properties exposed in the original RangeValidator. // The properties are got and set directly from the original RangeValidator. //////////////////////////////////////////////////////////////////////// /// [ Bindable(true), DefaultValue(""), MobileCategory(SR.Category_Behavior), MobileSysDescription(SR.RangeValidator_MaximumValue) ] public String MaximumValue { get { return _webRangeValidator.MaximumValue; } set { _webRangeValidator.MaximumValue = value; } } /// [ Bindable(true), DefaultValue(""), MobileCategory(SR.Category_Behavior), MobileSysDescription(SR.RangeValidator_MinimumValue) ] public String MinimumValue { get { return _webRangeValidator.MinimumValue; } set { _webRangeValidator.MinimumValue = value; } } /// [ Bindable(false), DefaultValue(ValidationDataType.String), MobileCategory(SR.Category_Behavior), MobileSysDescription(SR.RangeValidator_Type) ] public ValidationDataType Type { get { return _webRangeValidator.Type; } set { _webRangeValidator.Type = value; } } /// protected override bool EvaluateIsValid() { return EvaluateIsValidInternal(); } ///////////////////////////////////////////////////////////////////// // Helper function adopted from WebForms RangeValidator ///////////////////////////////////////////////////////////////////// /// protected override bool ControlPropertiesValid() { // Check if the control values can be converted to data type String maximumValue = MaximumValue; if (!WebCntrls.BaseCompareValidator.CanConvert(maximumValue, Type)) { throw new ArgumentException(SR.GetString( SR.Validator_ValueBadType, maximumValue, "MaximumValue", ID, PropertyConverter.EnumToString( typeof(ValidationDataType), Type) )); } String minumumValue = MinimumValue; if (!WebCntrls.BaseCompareValidator.CanConvert(minumumValue, Type)) { throw new ArgumentException(SR.GetString( SR.Validator_ValueBadType, minumumValue, "MinimumValue", ID, PropertyConverter.EnumToString( typeof(ValidationDataType), Type) )); } // Check for overlap. if (WebBaseCompareValidator.Compare(minumumValue, maximumValue, ValidationCompareOperator.GreaterThan, Type)) { throw new ArgumentException(SR.GetString( SR.RangeValidator_RangeOverlap, maximumValue, minumumValue, ID)); } return base.ControlPropertiesValid(); } // The reason of having this class is to expose the method // BaseCompareValidator.Compare which is a protected method in the // base class. Since the implementation of the method is not // trivial, instead of copying the code to this file, the following // subclass inherits the base class and expose a new public method // which calls its base implementation. While this solution doesn't // look elegant, it helps eliminate the code maintanence issue of // copying the code. private class WebBaseCompareValidator : BaseCompareValidator { // Have to define this method since it is abstract in the base // class. protected override bool EvaluateIsValid() { Debug.Assert(false, "Should never be called."); return true; } public static new bool Compare( String leftText, String rightText, ValidationCompareOperator op, ValidationDataType type) { return BaseCompareValidator.Compare(leftText, rightText, op, type); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BitmapEffectInput.cs
- BaseCodeDomTreeGenerator.cs
- GridViewCellAutomationPeer.cs
- OracleBoolean.cs
- UserPreferenceChangedEventArgs.cs
- EntitySetRetriever.cs
- _AutoWebProxyScriptHelper.cs
- ExpressionHelper.cs
- DataGridColumnEventArgs.cs
- SmiEventSink_DeferedProcessing.cs
- ListViewDeletedEventArgs.cs
- HtmlSelect.cs
- FrameworkElementFactoryMarkupObject.cs
- WebPartMenu.cs
- GlobalAclOperationRequirement.cs
- SvcMapFileSerializer.cs
- ArrayTypeMismatchException.cs
- AlphabeticalEnumConverter.cs
- XmlCountingReader.cs
- Command.cs
- OdbcTransaction.cs
- WebPartMenuStyle.cs
- PngBitmapDecoder.cs
- OleDbRowUpdatingEvent.cs
- SqlDataSourceView.cs
- PauseStoryboard.cs
- DockPattern.cs
- WindowsAuthenticationModule.cs
- CodeTypeParameterCollection.cs
- InvalidOleVariantTypeException.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- SecurityDescriptor.cs
- UIHelper.cs
- ScriptingWebServicesSectionGroup.cs
- SubpageParagraph.cs
- SemaphoreFullException.cs
- DockPatternIdentifiers.cs
- Visual3DCollection.cs
- InternalControlCollection.cs
- ObjectToModelValueConverter.cs
- ToolStripTextBox.cs
- StatusBarDrawItemEvent.cs
- smtpconnection.cs
- TextStore.cs
- RoutingService.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- DbDataReader.cs
- AuthorizationSection.cs
- TextElementCollection.cs
- TdsParser.cs
- DesignerDataTableBase.cs
- MsmqBindingFilter.cs
- XmlSchemaSimpleContent.cs
- ScrollChrome.cs
- GlyphShapingProperties.cs
- WindowsTooltip.cs
- CommandBindingCollection.cs
- SelectionItemPattern.cs
- _NegoState.cs
- DrawingVisual.cs
- ContractHandle.cs
- Collection.cs
- SHA1.cs
- CodePrimitiveExpression.cs
- GotoExpression.cs
- DelegatingTypeDescriptionProvider.cs
- StateMachineSubscriptionManager.cs
- ObjectListTitleAttribute.cs
- ErrorFormatter.cs
- _LocalDataStoreMgr.cs
- SqlCacheDependency.cs
- CodeObject.cs
- PlatformCulture.cs
- AttributeEmitter.cs
- SmtpNtlmAuthenticationModule.cs
- ConfigurationStrings.cs
- TemplateXamlTreeBuilder.cs
- DataGridViewTextBoxColumn.cs
- XmlHierarchicalEnumerable.cs
- Configuration.cs
- StoreAnnotationsMap.cs
- String.cs
- CleanUpVirtualizedItemEventArgs.cs
- InputBuffer.cs
- VirtualDirectoryMapping.cs
- PageSetupDialog.cs
- CodeTypeDelegate.cs
- TreeViewDesigner.cs
- FlowDocumentPageViewerAutomationPeer.cs
- AttachedPropertyMethodSelector.cs
- IDReferencePropertyAttribute.cs
- NamespaceEmitter.cs
- LingerOption.cs
- Unit.cs
- CatalogZoneDesigner.cs
- PermissionListSet.cs
- EqualityComparer.cs
- SingletonConnectionReader.cs
- WebZoneDesigner.cs
- ClientApiGenerator.cs