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

  • Home
  • SEARCH
  • 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 8650337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:47:43+00:00 2026-06-12T13:47:43+00:00

I trying to use remote validation for the first time, but am encountering problems

  • 0

I trying to use remote validation for the first time, but am encountering problems with the parameters passed inot the remote validation method.

My model is as follows:

public class PerinatalWomanView : IPerinatalWoman
{
[Required(ErrorMessage = "The woman's postcode is required")]
    [Display(Name = "Woman's postcode")]
    [Remote("PostcodeCheck", "Validation", "Validation")]
    [RegularExpression("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} [0-9][A-Za-z]{2}$", ErrorMessage = "A valid postcode is required")]
    public string Postcode { get; set; }

The view snippet is:

<div class="editor-label control-label">
  @Html.LabelFor(m => m.perinatalWomanView.Postcode)
</div>
div class="editor-field controls">
  @Html.EditorFor(m => m.perinatalWomanView.Postcode)
  @Html.ValidationMessageFor(m => m.perinatalWomanView.Postcode)
</div>

and the validation controller is:

public class ValidationController : Controller
{
    //
    // GET: /Validation/Validation/

    [HttpGet]
    public JsonResult PostcodeCheck(string Postcode)
    {

        //  postcode has already been checked for correct format
        //  now look it up to see if it exists

        string mbrraceCommonCodeEntitiesConnectionString = ConfigurationManager.ConnectionStrings["MbrraceCommonCodeEntities"].ConnectionString;
        if (PostcodeChecks.CheckPostcodeExists(mbrraceCommonCodeEntitiesConnectionString, Postcode))
        { return Json(true, JsonRequestBehavior.AllowGet); }

        return Json("This postcode was not found in the database", JsonRequestBehavior.AllowGet);

    }

When the controller is called the value of Postcode is null. The actual call – from Firebug – is:

http://localhost:57881/Validation/Validation /PostcodeCheck?perinatalWomanView.Postcode=OX4+1SU

How do I read the postcode string parameter correctly becuase it is clearly not null?

HELP!

  • 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-12T13:47:45+00:00Added an answer on June 12, 2026 at 1:47 pm

    You could have a view model like this:

    public class AddressViewModel
    {
        public string Postcode { get; set; }
    }
    

    and then use specify the Prefix by decorating the parameter with the [Bind] attribute:

    [HttpGet]
    public ActionResult PostcodeCheck(
        [Bind(Prefix = "perinatalWomanView")]AddressViewModel model
    )
    {
        // use model.Postcode here ...
    }
    

    or if you don’t want to use the Bind attribute have the following models:

    public class MyViewModel
    {
        public AddressViewModel PerinatalWomanView { get; set; }
    }
    
    public class AddressViewModel
    {
        public string Postcode { get; set; }
    }
    

    and then have your controller action take the view model:

    [HttpGet]
    public ActionResult PostcodeCheck(MyViewModel model)
    {
        // use model.PerinatalWomanView.Postcode here ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to either use the remote method, or add a method that mimics
Im trying to use the remote feature in the JQuery Validation Plugin to check
I'm trying to use git on windows to clone a remote repository. I can
I am trying to use local port forwarding to access remote host over a
I am trying to use python's telnetlib module to get information from a remote
I'm trying to use Unix cut to remove the first two fields per line.
Trying to use/learn git with a personal project. There's only me and a remote
I am trying to use OBJECT to embed content from a remote server into
I'm trying to use Microsoft.Sdc.Tasks.Web.Website.UpdateHttpErrorSetting to change the http error messages of a remote
Trying to use Net::SFTP, version 2.05 (appears to be the latest). But it fails

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.