/// <summary>
        /// Renders script block for display messages.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="showValidationErrors"></param>
        /// <returns></returns>
        public static IHtmlContent FeedbackMessageScript(this IHtmlHelper helper, bool showValidationErrors = false)
        {
            if (showValidationErrors)
            {
                FeedbackMessageUtil.AppendValidationErrorsToStore(helper.ViewContext);
            }

            return(new HtmlString("<script>" + FeedbackMessageSettings.Instance.ScriptBuilder.GetDomReadyScript() + "</script>"));
        }
        /// <summary>
        /// Renders feedback messages.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="messageRenderer"></param>
        /// <param name="showValidationErrors"></param>
        /// <returns></returns>
        public static IHtmlContent FeedbackMessagePanel(this IHtmlHelper helper, FeedbackMessageRenderer messageRenderer, bool showValidationErrors = false)
        {
            if (showValidationErrors)
            {
                FeedbackMessageUtil.AppendValidationErrorsToStore(helper.ViewContext);
            }

            return(new HtmlString(messageRenderer.RenderMessages().ToString()));
        }
        /// <summary>
        /// Renders feedback messages as ul, li.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="showValidationErrors"></param>
        /// <returns></returns>
        public static IHtmlString FeedbackMessagePanel(this HtmlHelper helper, bool showValidationErrors = false)
        {
            if (showValidationErrors)
            {
                FeedbackMessageUtil.AppendValidationErrorsToStore(helper.ViewContext);
            }

            return(MvcHtmlString.Create(FeedbackMessageSettings.Instance.MessageRenderer.RenderMessages().ToString()));
        }
 public FeedbackMessageScript()
 {
     validationStateChangedHandler = (sender, eventArgs) =>
     {
         if (ShowValidationErrors && CurrentEditContext != null)
         {
             FeedbackMessageUtil.AppendValidationErrorsToStore(CurrentEditContext);
         }
     };
 }
Esempio n. 5
0
        /// <summary>
        /// Render messages.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="output"></param>
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (ShowValidationErrors)
            {
                FeedbackMessageUtil.AppendValidationErrorsToStore(ViewContext);
            }

            output.TagName = "div";
            output.Content.AppendHtml(FeedbackMessageSettings.Instance.MessageRenderer.RenderMessages().ToString());
        }
Esempio n. 6
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);
            };
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 /// <summary>
 /// Adds validation error messages to <see cref="FeedbackMessageStore"/>.
 /// </summary>
 /// <param name="page"></param>
 /// <param name="validationGroup"></param>
 public static void AppendValidationErrorsToStore(this Page page, string validationGroup)
 {
     FeedbackMessageUtil.AppendValidationErrorsToStore(page, validationGroup);
 }
Esempio n. 9
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);
 }
Esempio n. 10
0
 /// <summary>
 /// Adds validation error messages to <see cref="FeedbackMessageStore"/>.
 /// </summary>
 /// <param name="page"></param>
 public static void AppendValidationErrorsToStore(this Page page)
 {
     FeedbackMessageUtil.AppendValidationErrorsToStore(page);
 }