Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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;
///
/// Checks if the value of
/// the associated input control is different from its initial value.
///
[
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 {
///
/// 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.
//------------------------------------------------------------------------------
//
// 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;
///
/// Checks if the value of
/// the associated input control is different from its initial value.
///
[
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 {
///
/// 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
- PriorityBinding.cs
- WizardStepBase.cs
- PropertyMapper.cs
- CodeObject.cs
- DodSequenceMerge.cs
- BinaryObjectReader.cs
- ManagementObject.cs
- XmlSchemaValidator.cs
- LoginCancelEventArgs.cs
- PrintController.cs
- ControlsConfig.cs
- DataGridViewBindingCompleteEventArgs.cs
- MailAddress.cs
- Queue.cs
- CodeRemoveEventStatement.cs
- FrugalList.cs
- ConnectorSelectionGlyph.cs
- ALinqExpressionVisitor.cs
- RemotingSurrogateSelector.cs
- LinqDataSourceView.cs
- LocalizableResourceBuilder.cs
- Wizard.cs
- EndpointAddressElementBase.cs
- ToolStripPanel.cs
- QuaternionAnimation.cs
- ThicknessAnimationBase.cs
- InstanceDataCollection.cs
- DataGridHeaderBorder.cs
- XMLDiffLoader.cs
- DataSetSchema.cs
- OciHandle.cs
- ApplicationProxyInternal.cs
- BinaryConverter.cs
- RelationshipManager.cs
- FreezableDefaultValueFactory.cs
- Rotation3DAnimationBase.cs
- FusionWrap.cs
- WaveHeader.cs
- AuthenticationService.cs
- EntityDataSourceState.cs
- IpcChannel.cs
- DigestTraceRecordHelper.cs
- ToolStripManager.cs
- DynamicMethod.cs
- precedingsibling.cs
- MSG.cs
- BindingExpressionUncommonField.cs
- DataGridTableCollection.cs
- Ray3DHitTestResult.cs
- WebPartConnectionsCloseVerb.cs
- PixelFormats.cs
- WindowsListViewScroll.cs
- CursorInteropHelper.cs
- Bitmap.cs
- InvariantComparer.cs
- AnimationStorage.cs
- PageAction.cs
- ReliableChannelListener.cs
- CustomTypeDescriptor.cs
- PropertyReferenceExtension.cs
- EventLogPermissionEntryCollection.cs
- SqlDataSource.cs
- StringUtil.cs
- ProxyWebPartManager.cs
- RequiredFieldValidator.cs
- IDReferencePropertyAttribute.cs
- DataGridViewRowsRemovedEventArgs.cs
- WizardPanelChangingEventArgs.cs
- MarshalDirectiveException.cs
- HierarchicalDataBoundControl.cs
- SHA384.cs
- ColumnResizeAdorner.cs
- ProviderConnectionPoint.cs
- ObjectTag.cs
- RootAction.cs
- CodeDirectoryCompiler.cs
- SevenBitStream.cs
- SpeechRecognitionEngine.cs
- ProfileSection.cs
- PolicyUnit.cs
- ResourceCategoryAttribute.cs
- Wizard.cs
- SystemUdpStatistics.cs
- WebServiceData.cs
- DivideByZeroException.cs
- SapiRecoInterop.cs
- DbConnectionOptions.cs
- DataControlCommands.cs
- DialogResultConverter.cs
- XmlAttributeOverrides.cs
- StoreUtilities.cs
- GridViewAutomationPeer.cs
- StorageModelBuildProvider.cs
- NotifyIcon.cs
- ValueUnavailableException.cs
- QilDataSource.cs
- HelloOperationAsyncResult.cs
- coordinatorscratchpad.cs
- ExpressionWriter.cs
- FileChangesMonitor.cs