Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / RequiredFieldValidator.cs / 1305376 / RequiredFieldValidator.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Web.UI.WebControls {
using System.ComponentModel;
using System.Web;
using System.Web.Util;
///
/// Checks if the value of
/// the associated input control is different from its initial value.
///
[
ToolboxData("<{0}:RequiredFieldValidator runat=\"server\" ErrorMessage=\"RequiredFieldValidator\">{0}:RequiredFieldValidator>")
]
public class RequiredFieldValidator : BaseValidator {
///
/// Gets or sets the initial value of the associated input control.
///
[
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;
}
}
///
///
/// 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PreloadedPackages.cs
- SerializationObjectManager.cs
- FileAuthorizationModule.cs
- MessageSmuggler.cs
- SecurityTokenReferenceStyle.cs
- SchemaSetCompiler.cs
- TextServicesLoader.cs
- AsyncDataRequest.cs
- Zone.cs
- ResXFileRef.cs
- DataSourceSelectArguments.cs
- ObjectStateFormatter.cs
- CacheHelper.cs
- AttributeConverter.cs
- WorkerRequest.cs
- ColumnMapProcessor.cs
- TableCellCollection.cs
- SqlCommandBuilder.cs
- MimeTypePropertyAttribute.cs
- TreeViewDataItemAutomationPeer.cs
- RequestDescription.cs
- MulticastOption.cs
- ProcessModelSection.cs
- ReadOnlyNameValueCollection.cs
- PackageRelationship.cs
- UdpConstants.cs
- _HelperAsyncResults.cs
- DefaultTextStore.cs
- TraceRecord.cs
- SettingsPropertyValue.cs
- TemplateBamlTreeBuilder.cs
- XmlAnyElementAttribute.cs
- ComponentRenameEvent.cs
- TraceUtility.cs
- DataGrid.cs
- RegexNode.cs
- _BufferOffsetSize.cs
- HostingEnvironmentException.cs
- ACE.cs
- IdnElement.cs
- ProxyFragment.cs
- FragmentQueryProcessor.cs
- EventLogEntry.cs
- IListConverters.cs
- WindowsTreeView.cs
- PropertyNames.cs
- SingleKeyFrameCollection.cs
- DupHandleConnectionReader.cs
- CurrentChangingEventManager.cs
- DataObjectAttribute.cs
- CheckBoxList.cs
- UpDownBase.cs
- EventLogPermissionEntryCollection.cs
- TextDecorationLocationValidation.cs
- Brushes.cs
- XmlSecureResolver.cs
- ErrorInfoXmlDocument.cs
- Control.cs
- MachineSettingsSection.cs
- WindowsAuthenticationEventArgs.cs
- PermissionSetEnumerator.cs
- ServiceHostingEnvironment.cs
- FilteredAttributeCollection.cs
- HttpResponseInternalBase.cs
- Error.cs
- Int16.cs
- SmtpCommands.cs
- ValidatedControlConverter.cs
- NetDataContractSerializer.cs
- AssociationTypeEmitter.cs
- EdmFunctions.cs
- ValueChangedEventManager.cs
- _AutoWebProxyScriptHelper.cs
- shaperfactoryquerycacheentry.cs
- ExpressionPrinter.cs
- Label.cs
- PropertyOverridesDialog.cs
- PriorityChain.cs
- ResXResourceSet.cs
- MemberDomainMap.cs
- XPathNodeIterator.cs
- UnaryQueryOperator.cs
- CodeTryCatchFinallyStatement.cs
- WebColorConverter.cs
- UnsafeNativeMethodsCLR.cs
- TransactionState.cs
- AutomationPatternInfo.cs
- BitmapEffectInput.cs
- DefaultShape.cs
- linebase.cs
- EntityDataSourceContainerNameItem.cs
- XmlElementAttribute.cs
- WizardPanelChangingEventArgs.cs
- Set.cs
- WebBrowserContainer.cs
- InputScopeNameConverter.cs
- SuppressMergeCheckAttribute.cs
- SqlRemoveConstantOrderBy.cs
- HighContrastHelper.cs
- HuffModule.cs