コード例 #1
0
        /// <summary>
        /// Adds validation error messages to <see cref="FeedbackMessageStore"/>.
        /// </summary>
        /// <param name="page"></param>
        /// <param name="option"></param>
        public static void AppendValidationErrorsToStore(Page page, FeedbackMessageRenderOption option)
        {
            var messageStore = FeedbackMessageStore.Current;

            if (option.ShowValidationErrors)
            {
                ValidatorCollection validators = page.GetValidators(option.ValidationGroup);

                foreach (FeedbackMessage errorMessage in GetErrorsAsFeedbackMessage(validators))
                {
                    messageStore.Add(errorMessage);
                }
            }

            if (option.ShowModelStateErrors)
            {
                ModelStateDictionary modelState = page.ModelState;
                if (!modelState.IsValid)
                {
                    foreach (FeedbackMessage errorMessage in GetErrorsAsFeedbackMessage(modelState))
                    {
                        messageStore.Add(errorMessage);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Appends javascript for display messages.
        /// </summary>
        /// <param name="control"></param>
        public static void AppendFeedbackMessageScripts(this Control control, FeedbackMessageRenderOption option = default)
        {
            control.Page.PreRenderComplete += (object sender, System.EventArgs e) =>
            {
                Page page = (Page)sender;

                FeedbackMessageUtil.AppendValidationErrorsToStore(page, option);

                page.ClientScript.RegisterStartupScript(page.GetType(), "FeedbackMessages.OnReady", FeedbackMessageSettings.Instance.ScriptBuilder.GetDomReadyScript(), true);
            };
        }
コード例 #3
0
        /// <summary>
        /// Adds validation error messages to <see cref="FeedbackMessageStore"/>.
        /// </summary>
        private void AddValidationErrors()
        {
            var renderOption = new FeedbackMessageRenderOption()
            {
                ShowModelStateErrors = this.ShowModelStateErrors,
                ShowValidationErrors = this.ShowValidationErrors,
                ValidationGroup      = this.ValidationGroup
            };

            FeedbackMessageUtil.AppendValidationErrorsToStore(Page, renderOption);
        }
コード例 #4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            var renderOption = new FeedbackMessageRenderOption()
            {
                ShowValidationErrors = true
            };

            this.AppendFeedbackMessageScripts(renderOption);

            //var messageRenderer = new FeedbackMessageRenderer();
            //messageRenderer.OuterTagName = "div";
            //messageRenderer.InnerTagName = "span";

            //messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.INFO,  "class", "ui info message");
            //messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.SUCCESS, "class", "ui success message");
            //messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.WARN, "class", "ui warn message");
            //messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.ERROR, "class", "ui error message");

            //FeedbackMessagePanel.MessageRenderer = messageRenderer;
        }
コード例 #5
0
 /// <summary>
 /// Adds validation error messages to <see cref="FeedbackMessageStore"/>.
 /// </summary>
 /// <param name="page"></param>
 /// <param name="option"></param>
 public static void AppendValidationErrorsToStore(this Page page, FeedbackMessageRenderOption option)
 {
     FeedbackMessageUtil.AppendValidationErrorsToStore(page, option);
 }