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 6370907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:59:28+00:00 2026-05-25T00:59:28+00:00

Folks, i am creating a new attribute which inhetirs from System.Web.Mvc.RemoteAttribute. I would like

  • 0

Folks, i am creating a new attribute which inhetirs from System.Web.Mvc.RemoteAttribute. I would like to override the method IsValid for that the validation also works without the enabled JavaScript. But i don’t know how i can acces to the additional fields. My code is:

[AttributeUsage(AttributeTargets.Property)]
public class DocumentationAttribute : System.Web.Mvc.RemoteAttribute
{
    public DocumentationAttribute()
        : base("ValidPass", "Validation")
    {
        base.HttpMethod = "Post";
    }
    private DocumentationAttribute(string routeName)
        : base(routeName)
    {

    }
    private DocumentationAttribute(string action, string controller)
        : base(action, controller)
    {

    }
    private DocumentationAttribute(string action, string controller, string areaName)
        : base(action, controller, areaName)
    {

    }

    public override bool IsValid(object value)
    {
        //How can i access to the additional fields?
    }}

Class Model:

        [Display(Name = "Passport")]
        [Documentation(ErrorMessage = "{0} not valid", AdditionalFields = "IDPass")]
        public virtual String Passport
        {
            set;
            get;
        }
  • 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-25T00:59:29+00:00Added an answer on May 25, 2026 at 12:59 am

    You can’t do remote validation without javascript. That’s how it works. You might as well just rely on server-side validation only, because that’s the only kind of validation that works without javascript.

    Are you trying to create a validator that works remotely with javascript, but does serverside if javascript is disabled? If so, then you should create a custom attribute derived from ValidationAttribute, and use remote as well.

    Specifically for your question, you need to create a public property in your attribute called AdditionalFields, this gets set in the initializer when you declare the property, then you can access the property from your IsValid.

    EDIT:

    Based on your additional information, you need to use the second form of IsValid that takes the validation context. You would do something like this:

    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        var fields = validationContext.ObjectType.GetProperty(this.AdditionalFields);
        var fieldsValue = (string)fields.GetValue(validationContext.ObjectInstance, null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Folks, We have been using OpenXml APIs found in System.IO.Packaging for creating a package
Folks, I'm tryning to extract data from web page using C#.. for the moment
Folks, I'm creating a new WCF Service and started with my Service interface. Looks
Folks, I'm working on a little piece of rich client software that I'd like
Folks, I really like the -Wshadow option since it helps to spot some possible
Folks, is there a collection of gotchas where Numpy differs from python, points that
Folks, I have a problem. I am a writing a script in python which
Is orthodox MVVM implementation pointless? I am creating a new application and I considered
Folks, I am creating an installer project in Visual Studio. This is done using
I'm creating an app on Windows Phone 7 that lets folks read offline HTML

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.