Exemplo n.º 1
0
        /// <summary>
        /// 呈现表单的验证结果
        /// </summary>
        /// <param name="result">表单验证结果</param>
        public void ShowValidationResult(IFormValidationResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            if (!result.HasError)//若没有验证失败的消息,则什么也不做
            {
                return;
            }


            foreach (var error in result.Errors)
            {
                ShowError(result.Form, error);
            }


            if (RemoveErrorMessageContainer)
            {
                foreach (var fieldName in result.Form.Controls.ControlNames.Except(result.Errors.Select(e => e.Name)))
                {
                    RemoveErrorMessage(result.Form, fieldName);
                }
            }


            ShowErrorSummary(result.Errors);
        }
Exemplo n.º 2
0
    /// <summary>
    /// 呈现表单的验证结果
    /// </summary>
    /// <param name="result">表单验证结果</param>
    public void ShowValidationResult( IFormValidationResult result )
    {

      if ( result == null )
        throw new ArgumentNullException( "result" );

      if ( !result.HasError )//若没有验证失败的消息,则什么也不做
        return;


      foreach ( var error in result.Errors )
        ShowError( result.Form, error );


      if ( RemoveErrorMessageContainer )
      {
        foreach ( var fieldName in result.Form.Controls.ControlNames.Except( result.Errors.Select( e => e.Name ) ) )
          RemoveErrorMessage( result.Form, fieldName );
      }


      ShowErrorSummary( result.Errors );

    }