Error when customize ValidationMessageFor

Posted by user1542080 on Stack Overflow See other posts from Stack Overflow or by user1542080
Published on 2012-09-11T09:57:56Z Indexed on 2012/09/11 15:38 UTC
Read the original article Hit count: 124

Filed under:

i want to customize ValidationMessageFor which display error. when i run application, a get an error : No overload for method 'ValidationMessageFor' takes 1 arguments

I'm understand my error, but i don't know how to fix it ? I need some suggest . Thanks you for reading!

My code :

    using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace OurCompanyUI.app_code
{
    public static class MyHtml
    {
        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
                                        this HtmlHelper<TModel> htmlHelper,
                                        Expression<Func<TModel, TProperty>> expression,
                                        string validationMessage,
                                        IDictionary<string, Object> htmlAttributes
                                    )
        {
            string modelName = ExpressionHelper.GetExpressionText(expression);
            TagBuilder p = new TagBuilder("p");
            p.InnerHtml = htmlHelper.ValidationMessageFor(htmlHelper,expression).ToString();
         //   p.InnerHtml = htmlHelper.ValidationMessageFor().ToString();
            return MvcHtmlString.Create(p.ToString(TagRenderMode.Normal)); 
        }   
    }
}

© Stack Overflow or respective owner

Related posts about asp.net-mvc-3