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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:40:21+00:00 2026-06-05T04:40:21+00:00

In the below code I cannot pass the username to the remote validation function:

  • 0

In the below code I cannot pass the username to the remote validation function:

public string UserName { get; set; }

public class Numbers
{


            [Display(Name = "Additonal Numbers")]
            [Remote("NumberExists", "Account", AdditionalFields = "UserName", ErrorMessage = "Serial is already taken.")]
            public string additionalNumbers { get; set; }
 }


public List<Numbers> NumberList { get; set; }

This is a simple example but I would like to pass additional fields from the same model within a list but I cant seem to access anything outside the scope of the public class.

Do I need to pass the rest of the model into the list in some way to achieve this or am I doing something wrong here?

  • 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-06-05T04:40:24+00:00Added an answer on June 5, 2026 at 4:40 am

    The AdditionalFields parameter in the remote validation attribute need to be in the same class as the object being validated.

    ..edit..

    public class Numbers
    {
    
                public string UserName { get; set; }
    
                [Display(Name = "Additonal Numbers")]
                [Remote("NumberExists", "Account", AdditionalFields = "UserName", ErrorMessage = "Serial is already taken.")]
                public string additionalNumbers { get; set; }
     }
    

    ..edit after comments..
    It looks like what you want to do is validate that all the numbers are unique for a Username. Try this:

    public string UserName { get; set; }
    
    [Display(Name = "Additonal Numbers")]
    [Remote("NumberExists", "Account", AdditionalFields = "UserName", ErrorMessage = "Serial is already taken.")]
    public List<String> NumberList { get; set; }
    

    In your NumberExists Action take a List of Strings rather than only 1 string. This will let you validate your whole array all at once.

    Public ActionResult NumberExists(List<String> NumberList, String UserName){
        //Validate list is unique for username
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use below code query database, I cannot get any result, but I
I am using the below code to search a mysql database but cannot get
i'm getting error cannot find symbol in netbeans while using the below code for
I cannot understand why the code below is giving me this error in firebug
After loosing much sleep I still cannot figure this out: The code below (its
I get an error in the bellow code it says I cannot convert method
I want to pass a string to my CreateProcess function so that I can
I want to pass sys date to my procedure. Below is my code snippet
Below code is for donwnloading file from azure blob. I have problem with .docx,.xlsx
Below code checks for last item but I need to check for the second

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.