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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:23:11+00:00 2026-06-17T04:23:11+00:00

I’m not so experienced using MVC. I’m dealing with this situation. Everything works well

  • 0

I’m not so experienced using MVC. I’m dealing with this situation. Everything works well until call the HttpPost method where has all its members null. I don’t know why is not persisting all the data on it.

And everything works well, because I can see the data in my Html page, only when the user submit the information is when happens this.

    [HttpGet]
    public ActionResult DoTest()
    {
        Worksheet w = new Worksheet(..);
        return View(w);
    }

    [HttpPost]
    public ActionResult DoTest(Worksheet worksheet)
    {
        return PartialView("_Problems", worksheet);
    }

enter image description here

This is class which I’m using.

public class Worksheet
{
    public Worksheet() { }

    public Worksheet(string title, List<Problem> problems)
    {
        this.Title = title;
        this.Problems = problems;
    }

    public Worksheet(IEnumerable<Problem> problems, WorksheetMetadata metadata, ProblemRepositoryHistory history)
    {
        this.Metadata = metadata;
        this.Problems = problems.ToList();
        this.History = history;
    }

    public string Title { get; set; }
    public List<Problem> Problems { get; set; }  // Problem is an abstract class
    public WorksheetMetadata Metadata { get; set; }
    public ProblemRepositoryHistory History { get; set; }
}

And my razor view…. the razor view shows successfully my view. I realized something rare, please note in my 5 and 6 lines that I have HiddenFor method, well if I used that, when calls HTTPPOST persists the data, I don’t know why.

@model Contoso.ExercisesLibrary.Core.Worksheet

<div id="problemList">
<h2>@Html.DisplayFor(model => model.Metadata.ExerciseName)</h2>
    @Html.HiddenFor(model => model.Metadata.ExerciseName)
    @Html.HiddenFor(model => model.Metadata.ObjectiveFullName)

@for (int i = 0; i < Model.Problems.Count; i++)
{
    <div>
    @Html.Partial(Contoso.ExercisesLibrary.ExerciseMap.GetProblemView(Model.Problems[i]), Model.Problems[i])
    </div>
}
</div>

UPDATE
I’m using a static class to get the view name, but as I’m testing I’m just using this Partial view

@model Contoso.ExercisesLibrary.AbsoluteArithmetic.Problem1
<div>

    <span style="padding:3px; font-size:18px;">@Model.Number1</span>
    <span style="padding:5px; font-size:18px;">+</span>
    <span style="padding:5px; font-size:18px;">@Model.Number2</span>
    <span style="padding:5px; font-size:18px;">=</span>

    <span style="font-size:18px">
            @Html.EditorFor(model => model.Result, new { style = "width:60px; font-size:18px;" })
            @Html.ValidationMessageFor(model => model.Result)
    </span>
</div>

@section Scripts {

}

And here the user do the post

@model Contoso.ExercisesLibrary.Core.Worksheet

<form method="post">
    @Html.Partial("_Problems", Model)

    <input type="submit" value="Continue" />
</form>
  • 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-17T04:23:13+00:00Added an answer on June 17, 2026 at 4:23 am

    The Model Binder will ‘bind’ or link input fields on your view to the model. It will not bind display fields (like label), that is why you need the HiddenFor it will add an <input type="hidden" which will then be bound to the Model when you Post.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

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.