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 Raut81 reputationPosted Dec 5, 2017, 8:11 PM EST
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 5, 2017, 9:34 PM EST
Faizan Syed21 reputationPosted Dec 5, 2017, 9:38 PM EST