当前位置: 首页>>代码示例>>C#>>正文


C# Validator.NoteErrorAndAddMessage方法代码示例

本文整理汇总了C#中Validator.NoteErrorAndAddMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.NoteErrorAndAddMessage方法的具体用法?C# Validator.NoteErrorAndAddMessage怎么用?C# Validator.NoteErrorAndAddMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator.NoteErrorAndAddMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateAndGetPostBackDuration

 /// <summary>
 /// Validates and returns the duration, a secondary validation in case javascript is disabled on the client system.
 /// </summary>
 public TimeSpan ValidateAndGetPostBackDuration( PostBackValueDictionary postBackValues, Validator validator, ValidationErrorHandler validationErrorHandler )
 {
     if( tooLongOrInvalidCharacters( durationPicker.GetPostBackValue( postBackValues ) ) ) {
         validator.NoteErrorAndAddMessage( "Please enter a valid duration." );
         return TimeSpan.Zero;
     }
     return validator.GetTimeSpan( validationErrorHandler, parseTimeSpan( durationPicker.GetPostBackValue( postBackValues ) ) );
 }
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:11,代码来源:DurationPicker.cs

示例2: ValidateUploadedFile

        /// <summary>
        /// Uploaded file cannot be null. But if uploadedFile.HasFile is false, this will be a no-op.
        /// Pass null for acceptableFileExtensions if there is no restriction on file extension.
        /// PerformAdditionalImageValidation cannot be null but may be an empty delegate.
        /// </summary>
        public static void ValidateUploadedFile(
            Validator validator, EwfFileUpload uploadedFile, string[] acceptableFileExtensions, Action<Validator, System.Drawing.Image> performAdditionalImageValidation,
            bool mustBeRenderableImage)
        {
            var file = uploadedFile.GetPostBackValue( AppRequestState.Instance.EwfPageRequestState.PostBackValues );
            if( file == null )
                return;

            // Perform generic file validation.
            if( acceptableFileExtensions != null && !FileExtensions.MatchesAGivenExtension( file.FileName, acceptableFileExtensions ) ) {
                validator.NoteErrorAndAddMessage( Translation.UnacceptableFileExtension + " " + acceptableFileExtensions.GetCommaDelimitedStringFromCollection() );
                // Don't bother trying to see if it's an image and parse the image. The file extension message be more detailed than the messages those errors produce.
                return;
            }

            // Perform image-specific validation if necessary.
            if( mustBeRenderableImage ) {
                // Make sure it is an image according to its content type.
                if( !ContentTypes.IsImageType( GetContentTypeForPostedFile( file ) ) )
                    validator.NoteErrorAndAddMessage( "Please upload a valid image file." );
                else {
                    // Make sure it is an image type that we understand. Also perform optional custom validation.
                    try {
                        using( var stream = new MemoryStream( file.Contents ) ) {
                            var image = System.Drawing.Image.FromStream( stream );
                            performAdditionalImageValidation( validator, image );
                        }
                    }
                    catch( ArgumentException ) {
                        // If we end up in this catch block, it means that System.Drawing.Image does not understand our image. Since we already know that our content type
                        // is image at this point, this usually means that the file is some sort of unsupported image format, like NEF.
                        validator.NoteErrorAndAddMessage( "The uploaded image file is in an unsupported format." );
                    }
                }
            }
        }
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:41,代码来源:BlobFileOps.cs

示例3: validateFormValues

 private void validateFormValues(
     Validator validator, string subject, bool requireUploadIfNoFile, Action<Validator, System.Drawing.Image> validateImage, bool mustBeImage)
 {
     BlobFileOps.ValidateUploadedFile( validator, uploadedFile, acceptableFileExtensions, validateImage, mustBeImage );
     if( requireUploadIfNoFile && file == null && !uploadedFile.ValueChangedOnPostBack( AppRequestState.Instance.EwfPageRequestState.PostBackValues ) )
         validator.NoteErrorAndAddMessage( Translation.PleaseUploadAFile + " '" + subject + "'." );
 }
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:7,代码来源:BlobFileManager.cs

示例4: ValidateAndGetPostBackDate

 /// <summary>
 /// Validates the date and returns the date.
 /// </summary>
 public DateTime ValidateAndGetPostBackDate( PostBackValueDictionary postBackValues, Validator validator, ValidationErrorHandler errorHandler )
 {
     var date = validator.GetDateTime( errorHandler, textBox.GetPostBackValue( postBackValues ), null, min, max );
     if( errorHandler.LastResult == ErrorCondition.NoError && date.HasTime() )
         validator.NoteErrorAndAddMessage( "Time information is not allowed." );
     return date;
 }
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:10,代码来源:DatePicker.cs

示例5: ValidatePassword

 // Adding a New User
 /// <summary>
 /// Ensures that the specified data values contain identical, valid password values.
 /// </summary>
 public static void ValidatePassword( Validator validator, DataValue<string> password, DataValue<string> passwordAgain )
 {
     if( password.Value != passwordAgain.Value )
         validator.NoteErrorAndAddMessage( "Passwords do not match." );
     else {
         var strictProvider = SystemProvider as StrictFormsAuthUserManagementProvider;
         if( strictProvider != null )
             strictProvider.ValidatePassword( validator, password.Value );
         else if( password.Value.Length < 7 )
             validator.NoteErrorAndAddMessage( "Passwords must be at least 7 characters long." );
     }
 }
开发者ID:enduracode,项目名称:enterprise-web-library,代码行数:16,代码来源:FormsAuthStatics.cs


注:本文中的Validator.NoteErrorAndAddMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。