Hi All,
I want to pass the model from view to controller using Ajax
But I am getting null paramter value. Iam not able to understand where iam wrong.
- //Model Class
- public class CNModel
- {
- public CNModel()
- {
- }
- public string ID { get; set; }
- public string Name { get; set; }
- }
- //csHTML
- @model CN_MVC.Models.CNModel
- @using Newtonsoft.Json
- @using (Html.BeginForm(new { @id = "CNform" }))
- {
- @Html.TextBoxFor(m => m.ID, new { @class = "form-control", id = "txtID", placeholder = "Enter ID"})
- @Html.TextBoxFor(m => m.Name new { @class = "form-control", id = "txtName", placeholder = "Enter Name"})
- "button" id="btnShow" class="btn" value="Pass To Controller" onclick="Show()" />
- }
- //Controller
- [HttpPost]
- [AcceptVerbs(HttpVerbs.Post)]
- public string Show(string modelParameter)
- {
- var DeserializedModel = JsonConvert.DeserializeObject
(modelParameter); - }

Gaurav RautPosted Dec 6, 2017, 1:11 AM
Faizan SyedPosted Dec 6, 2017, 2:38 AM
Pravin GhadgePosted Dec 6, 2017, 2:34 AM