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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:22:21+00:00 2026-06-09T19:22:21+00:00

I have a simple model which models a vehicle entity. It has attributes: Model

  • 0

I have a simple model which models a vehicle entity.
It has attributes:
Model
Make
Colour
RegistrationPlate

On the create View I want to users to be able to perform a server look up using the registration plate to auto fill the Model/Make/Colour information.

As such I’m trying to create an action link like so:

@Html.ActionLink("Look up registration", "RegLookup", "Vehicle", Model.Registration)

Where RegLookup is a get ActionResult method in the vehicle controller which goes away and finds the model/make/colour information based on the registration field passed through to it. The Make/Model/Colour information is retrieved from a separate database.

However at present on rendering the view – before even getting to the action link – an exception is thrown indicating that the Model is Null.

What I want to be passed through is effectively the value from the textbox representing the registration:

@Html.EditorFor(model => model.Registration)

How do I pass this value through?

  • 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-09T19:22:23+00:00Added an answer on June 9, 2026 at 7:22 pm

    In your CreateView, typically your Model Properties should mostly be empty except some prepoulated values like dropdowns . What you should use is to use jQuery ajax to make an async call to an action method which returns the relevant data based on the registration plate and fill that in the Form

    You may keep the action link like this

    @Html.ActionLink("Look up registration", "RegLookup", "Vehicle",
                                                          new {@id="check"},null)
    

    And attach a javascript function to the click event of it to make the ajax call

    $(function(){
    
      $("#check").click(function(e){
        e.preventDefault();
        var item=$(this);
        var regPlateVal=$("#RegistrationPlate").val();
        $.getJSON(item.attr("href")+"?registration="+regPlateVal,function(data){
           if(data.Status=="success")
           {
             $("#Color").val(data.Color);
             $("#Model").val(data.Model);
           }
        });
      });
    
    });
    

    Assuming your RegLookUp action method accept a parameter (With name registration) and returns the data in JSON format like below format

    {
      "Status": "success",
       "Color": "Red",
       "Model": "2011"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables
I have a model which has a field status definde as: class Model(models.Model): ...
I have a simple model which looks like this: class Group(models.Model): name = models.CharField(max_length
I have two simple tables in Django which looks like: class Session(models.Model): id =
Hello I have a model named Client which has nested models called Receiver and
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I have a simple User model which is associated to many Town objects using
I have a simple model class (Part), which pulls from it's information from a
Simple rails app: I have 2 models, user and intro [which is simply a
I have a simple model like this one: class Artist(models.Model): surname = models.CharField(max_length=200) name

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.