Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / RequiredFieldValidator.cs / 1 / RequiredFieldValidator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Web.UI.WebControls { using System.ComponentModel; using System.Web; using System.Security.Permissions; using System.Web.Util; ////// [ ToolboxData("<{0}:RequiredFieldValidator runat=\"server\" ErrorMessage=\"RequiredFieldValidator\">{0}:RequiredFieldValidator>") ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class RequiredFieldValidator : BaseValidator { ///Checks if the value of /// the associated input control is different from its initial value. ////// [ WebCategory("Behavior"), Themeable(false), DefaultValue(""), WebSysDescription(SR.RequiredFieldValidator_InitialValue) ] public string InitialValue { get { object o = ViewState["InitialValue"]; return((o == null) ? String.Empty : (string)o); } set { ViewState["InitialValue"] = value; } } ///Gets or sets the initial value of the associated input control. ////// /// AddAttributesToRender method /// protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (RenderUplevel) { string id = ClientID; HtmlTextWriter expandoAttributeWriter = (EnableLegacyRendering) ? writer : null; AddExpandoAttribute(expandoAttributeWriter, id, "evaluationfunction", "RequiredFieldValidatorEvaluateIsValid", false); AddExpandoAttribute(expandoAttributeWriter, id, "initialvalue", InitialValue); } } ////// /// EvaluateIsValid method /// protected override bool EvaluateIsValid() { // Get the control value, return true if it is not found string controlValue = GetControlValidationValue(ControlToValidate); if (controlValue == null) { Debug.Fail("Should have been caught by PropertiesValid check"); return true; } // See if the control has changed return(!controlValue.Trim().Equals(InitialValue.Trim())); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Web.UI.WebControls { using System.ComponentModel; using System.Web; using System.Security.Permissions; using System.Web.Util; ////// [ ToolboxData("<{0}:RequiredFieldValidator runat=\"server\" ErrorMessage=\"RequiredFieldValidator\">{0}:RequiredFieldValidator>") ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class RequiredFieldValidator : BaseValidator { ///Checks if the value of /// the associated input control is different from its initial value. ////// [ WebCategory("Behavior"), Themeable(false), DefaultValue(""), WebSysDescription(SR.RequiredFieldValidator_InitialValue) ] public string InitialValue { get { object o = ViewState["InitialValue"]; return((o == null) ? String.Empty : (string)o); } set { ViewState["InitialValue"] = value; } } ///Gets or sets the initial value of the associated input control. ////// /// AddAttributesToRender method /// protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (RenderUplevel) { string id = ClientID; HtmlTextWriter expandoAttributeWriter = (EnableLegacyRendering) ? writer : null; AddExpandoAttribute(expandoAttributeWriter, id, "evaluationfunction", "RequiredFieldValidatorEvaluateIsValid", false); AddExpandoAttribute(expandoAttributeWriter, id, "initialvalue", InitialValue); } } ////// /// EvaluateIsValid method /// protected override bool EvaluateIsValid() { // Get the control value, return true if it is not found string controlValue = GetControlValidationValue(ControlToValidate); if (controlValue == null) { Debug.Fail("Should have been caught by PropertiesValid check"); return true; } // See if the control has changed return(!controlValue.Trim().Equals(InitialValue.Trim())); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeNamespaceImport.cs
- DispatcherSynchronizationContext.cs
- ReadOnlyActivityGlyph.cs
- FixedDocument.cs
- SQLBytes.cs
- GlyphShapingProperties.cs
- ConfigXmlWhitespace.cs
- TextServicesProperty.cs
- FreeFormDesigner.cs
- MouseGesture.cs
- CompareInfo.cs
- DirectoryObjectSecurity.cs
- CompressionTransform.cs
- PageCodeDomTreeGenerator.cs
- SqlDataSourceSummaryPanel.cs
- ManagedIStream.cs
- Transactions.cs
- BitmapEffectInputData.cs
- FilterQueryOptionExpression.cs
- InvalidDataContractException.cs
- Drawing.cs
- SessionChannels.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- SqlInfoMessageEvent.cs
- ErrorWebPart.cs
- SqlDataSourceSelectingEventArgs.cs
- XamlSerializerUtil.cs
- RootBrowserWindow.cs
- WebBrowserSiteBase.cs
- CreateRefExpr.cs
- ActivityCollectionMarkupSerializer.cs
- RangeContentEnumerator.cs
- FileUtil.cs
- XmlWriterSettings.cs
- RemotingServices.cs
- Form.cs
- IResourceProvider.cs
- ZipPackagePart.cs
- SchemaManager.cs
- CatalogPartCollection.cs
- DataBindingHandlerAttribute.cs
- DataServiceCollectionOfT.cs
- ListViewDeletedEventArgs.cs
- Application.cs
- ContractMapping.cs
- CommandField.cs
- OutputCacheModule.cs
- BitmapCacheBrush.cs
- TextProperties.cs
- CLSCompliantAttribute.cs
- HandleCollector.cs
- ProvideValueServiceProvider.cs
- SqlInternalConnection.cs
- serverconfig.cs
- BrowserCapabilitiesFactory.cs
- TextLineBreak.cs
- DataGridViewAdvancedBorderStyle.cs
- TemplateColumn.cs
- IconHelper.cs
- HttpServerVarsCollection.cs
- ServerType.cs
- NodeInfo.cs
- SimpleTypeResolver.cs
- OracleFactory.cs
- SchemaReference.cs
- AlgoModule.cs
- CodeTypeReferenceCollection.cs
- ArrangedElementCollection.cs
- StringStorage.cs
- CrossSiteScriptingValidation.cs
- IndependentlyAnimatedPropertyMetadata.cs
- xdrvalidator.cs
- AesCryptoServiceProvider.cs
- IItemContainerGenerator.cs
- InArgumentConverter.cs
- SpellerInterop.cs
- ControlUtil.cs
- FileDetails.cs
- StringFormat.cs
- ChannelTokenTypeConverter.cs
- XmlHierarchicalDataSourceView.cs
- Visual.cs
- RuntimeCompatibilityAttribute.cs
- ObfuscationAttribute.cs
- StringOutput.cs
- XamlStream.cs
- TextRangeEditLists.cs
- DataServiceHostFactory.cs
- Attributes.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- EnumUnknown.cs
- SqlAliaser.cs
- XslCompiledTransform.cs
- EventListener.cs
- Vector3dCollection.cs
- InvokeGenerator.cs
- TdsValueSetter.cs
- IndexedEnumerable.cs
- ListItemParagraph.cs
- LiteralControl.cs