Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:50:07+00:00 2026-05-26T09:50:07+00:00

i have wrote a extension method for customize my validation messages, like this: namespace

  • 0

i have wrote a extension method for customize my validation messages, like this:

 namespace Helpers
{
public static class HtmlHelpers
{
    public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
    {
        var sb = new StringBuilder();

        string modelName = ExpressionHelper.GetExpressionText(expression);
        ModelState state = htmlHelper.ViewData.ModelState[modelName];
        if (state != null)
            if ((state.Errors != null) && (state.Errors.Count > 0))
            {
                sb.Append("<div class='error-left'></div>");
                sb.Append("<div class='error-inner'>");
                sb.Append(htmlHelper.ValidationMessageFor(expression).ToString());
                sb.Append("</div>");
            }

        return MvcHtmlString.Create(sb.ToString());
    }
}
}

So in my view, i put

@using HtmlHelpers

and also

@Html.ValidationMessageFor(model => model.Name)

But i’m getting this exception:

The call is ambiguous between the following methods or properties: 'ContinentalWeb.Helpers.HtmlHelpers.ValidationMessageFor<ContinentalWeb.Models.Maker,string>(System.Web.Mvc.HtmlHelper<Type>, System.Linq.Expressions.Expression<System.Func<Type,string>>)' and 'System.Web.Mvc.Html.ValidationExtensions.ValidationMessageFor<Type,string>(System.Web.Mvc.HtmlHelper<Type>, System.Linq.Expressions.Expression<System.Func<Type,string>>)'

I’m new in MVC… any help?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:50:07+00:00Added an answer on May 26, 2026 at 9:50 am

    Your extension method has the same name and signature as the default one. This is not possible because you cannot have the 2 at the same time in scope. You will have to give a different name to your method or change the number and/or type of arguments to avoid the conflict.

    For example:

    public static MvcHtmlString CustomValidationMessageFor<TModel, TProperty>(
        this HtmlHelper<TModel> htmlHelper, 
        Expression<Func<TModel, TProperty>> expression
    )
    {
        ...
    }
    

    and then use it like this:

    @Html.CustomValidationMessageFor(model => model.Name)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an extension method that looks like the following: //[MethodImpl(MethodImplOptions.NoOptimization)] public static IEnumerable<char>
Lets say I have this extention method: public static bool HasFive<T>(this IEnumerable<T> subjects) {
Let's say I have the following method: public static int CountNonNullMembers<T>(this IEnumerable<T> enumerable) {
I have an extension method that I wrote but when I use it on
I have a piece of code like the following: public class ActivityHelper { public
I have some extension methods which could be used like this: MyType myObject; string
I have this Array i wrote a function MostFreq that takes an array of
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
I have a couple of unit test helper extension methods, such as, IsNotEmpty(this string
I like the way in C# where you can write an extension method, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.