How to Save Data From Rating Control when passed to Controller

Good Evening,


When a user clicks on a rating on a form and then submits the form, how do I pass the value of the rating control to the MVC controller?

Thanks,
Steven

1 Reply 1 reply marked as answer

KR Keerthana Rajendran Syncfusion Team January 28, 2021 08:17 AM UTC

Hi Steven, 
 
Thanks for contacting Syncfusion support. 
 
You can retrieve the Rating control value in controller during form submit using form collection. The name attribute of rating input will be updated based on the Id of Rating control. Based on this id, you can get the value of rating in collections as shown below 
 
 
 
Refer to the following code 
 
@using (Html.BeginForm("OnPost", "Home")) 
{ 
    <h2>EJ1 Rating</h2> 
    @Html.EJ().Rating("StarRating") 
 
  <button type="submit" id="submit">Submit</button> 
} 
 
Controller: 
 
[HttpPost] 
        public ActionResult OnPost(FormCollection collection) 
        { 
            var value = collection["StarRating"]; 
            return View("Index"); 
        } 
 
We have attached a sample for your reference in the following link 
 
 
Please refer to the following links for more details on Rating control 
 
 
 
 
Please let us know if you need further assistance. 
 
Regards, 
Keerthana.  


Marked as answer
Loader.
Up arrow icon