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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:35:57+00:00 2026-06-03T06:35:57+00:00

I have a problem with an ASP.NET MVC page that shows a list of

  • 0

I have a problem with an ASP.NET MVC page that shows a list of orders being dispatched to a particular location. The page is called Orders/DispatchToCentre/2 where 2 is the ID of the Centre from the database and it displays fine.

The trouble is that I want to be able to postback changes to the orders on the page, so I’m doing this:

<dl class="orders">
@foreach (OrderViewModel ovm in Model)
{
    <dd>@ovm.User.Name </dd>
    <dt>
    @Html.Partial("OrderTable", ovm)
    <p>
    @using (Html.BeginForm("Dispatch", "Order", new { id = ovm.Id }, FormMethod.Post ) )
    {
       @Html.TextBox("id", ovm.Id );
       @Html.Hidden("OriginatingPage", Request.Path);
       <input type="submit" name="submit-@ovm.Id" value="Order dispatched" />         
    }   
    </p>

    </dt>
}
</dl>

The problem is that when I look at the page source I get this:

  <p>
    <form action="/Order/Dispatch/3f180e5b-d112-4245-98ef-602e86eccda6" method="post">
      <input id="id" name="id" type="text" value="2" />
      <input id="OriginatingPage" name="OriginatingPage" type="hidden" value="/Order/DispatchToCentre/2" />       
      <input type="submit" name="submit-3f180e5b-d112-4245-98ef-602e86eccda6" value="Order dispatched" />         
    </form>    
  </p>

The id input appears to have totally ignored the OrderViewModel.Id that I am explicitly setting it to ( this should be a Guid ) and automatically set itself to use the Centre Id from the path instead.

Is there some configuration I need to use to avoid this bit of interfering automagicalness or am I best just to ignore the helper here and create the field manually? Obviously, the latter is a fairly trivial task but it would be helpful to understand if I am conceptually misunderstanding some important facet of the Razor rendering action or I’m just running into a quirk.

  • 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-03T06:35:58+00:00Added an answer on June 3, 2026 at 6:35 am

    In controller, HttpGet action, before returning view, you should call

    ModelState.Remove("id");
    

    Fact is that ModelState has higher priority in providing model values than the model itself, so value from ModelState is always preferred (if any) over model value

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

Sidebar

Related Questions

I have an ASP.NET MVC Page that i have to display the fields in
i have to create one asp.net mvc page that will show template of controls.
i have a problem i am developing an asp.net mvc project. Website is in
i have a problem with session in my webapplication (asp.net mvc rc2). the application
I have a frustrating problem with an asp.net mvc view containing the Microsoft Chart
I am trying to learn ASP.NET MVC and I hit this problem: I have
I'm trying out ASP.NET MVC routing and have of course stumbled across a problem.
I am working in Asp.Net 4.0 C#-- MVC-3 . I have one problem and
everybody; I have this problem in asp.net, I have a page where I insert
I have a problem with an ASP.NET application that is driving me nuts. When

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.