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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:47:15+00:00 2026-06-07T01:47:15+00:00

I have a view tied to a strongly typed ViewModel but I’m not using

  • 0

I have a view tied to a strongly typed ViewModel but I’m not using the MVC3 HTML helpers, just normal HTML input tags. However, this seems to not be passing the values correctly to the action method as the ViewModel is entirely null.

ViewModel:

class QuoteSearch {
    public long? CustomerId { get; set; }
    public string CustomerFirstName { get; set; }
    public string CustomerLastName { get; set; }
}

View:

@model QuoteSearch

<form action="/quotes/search" method="POST">
    <p>Customer ID: <input id="CustomerIdField" name="CustomerId" type="text" /></p>
    <p>Customer First Name: <input id="CustomerFirstNameField" name="CustomerFirstName" type="text"/></p>
    <p>Customer Last Name: <input id="CustomerLastNameField" name="CustomerLastName" type="text"/></p>
    <p><button id="SearchButton" type="submit">Search</button></p>
</form>

Controller:

 [HttpPost]
 public ActionResult Search(QuoteSearch search) { 
     // checking if fields are set here.
 }

I seem to remember there being a way to NOT have to use the Html helpers but still use a strongly-typed model (as opposed to a FormCollection); I thought it involved setting the name attribute to be the exact name of the property on the model, but I seem to have been mistaken.

  • 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-07T01:47:16+00:00Added an answer on June 7, 2026 at 1:47 am

    Your names don’t all align (as suggested in the comments) but for the fields that do line up, the model is correctly populated when I execute the above code (names are there, CustomerId is null).

    Are you setting a breakpoint, and do you know that the code is being hit?

    Please also confirm that your controller is called Quotes. Even if it is, you will be better to use:

    <form action="@Url.Action("search", "quotes")" method="POST">
    

    …so that routing works even if you add areas etc. The Url helper will work out the correct path for the request based on your routing rules.

    Finally, if you’re not hitting that execution point with a breakpoint set, be sure to use F12/dev tools to monitor your network requests and make sure that the correct address is being called. The above snippet should also help resolve that.

    Hope that helps some.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have view like 'home/details/5', it can be access by anonymous user. but there
I have a view with IBActions tied to UITextFields and UIButtons. They all work
I'm just starting my first MVC3 application, and I'm not sure how to unit-test
In my scenario I have 2 view controllers, one tied to the main view
I have a button in a Nib based view which does not behave like
I have a combobox in a view that is tied to a data store
I have a view with a drop down, which is tied to the view
I have view on which I defined a custom tagName. I need to be
I have view controller, into the view i have put a table view, and
i have view controller which contains a button which show the image library ,if

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.