Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I pass an altered Model to a Controller from View
    primarykey
    data
    text
    <p>I'm new to MVC and having a rough time with this. I have read many posts and books and done tutorials and I am now going to ask the public for help.</p> <p>My situation:</p> <p>I am upgrading part of a classic ASP website to MVC. It is the FAQ portion of the website.</p> <p>I've got a controller called FAQController and a View Result called, Display, that takes in the parameters Year and faqID and then displays the related FAQ information in the view.</p> <p>I want to be able to have a user rate how helpful the FAQ was by clicking on a set of links or buttons that will look like stars (1-star through 5-star ratings)</p> <p>I want the onclick event of the buttons to route to an [HttpPost] ViewResult that then stores the rating in a database and returns them to the previous view with whatever selection they made highlighted. So if they click 4 stars after the information is submitted 4 stars would be highlighted.</p> <p>So I have an int rating property in my model that I want to be able to change in the view, then update to a database, and then display the change once the view loads again.</p> <p>My question is what is a good way to change the Rating value of the Model before I resubmit the model to the controller?</p> <p>I see I can use @Html.Hiddenfor(m => Model.FAQRating) to get the value of the first model rating (which by default is 0) but how should I go about setting that value before I resubmit the form to the controller.</p> <p>Am I even thinking about this correctly? I thought I might be able to add a "rating" parameter to the Display view result but that seemed dumb.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload