Abhilash J A

Abhilash J A

  • 530
  • 2.4k
  • 599k

MVC 5 - viewmodel object not binding view issue.

Mar 1 2017 3:47 AM
Hello Everyone,
 
This Ajax call on button click,
  1. $('#idProject').click(function () {  
  2.     var idProject = $(this).attr('name');  
  3.     $.ajax({  
  4.         url: "/UserRegister/GetProjectByID?projectid=" + idProject,  
  5.         type: "POST",  
  6.         success: function (result) {  
  7.             //alert(result);  
  8.         }  
  9.     });  
  10. }); 
View page,
  1. @model Reboxwebapp.Models.ViewModel.PartnerProjectVM 

  2.              @Html.TextBoxFor(model => model.ProjectName, new { @id = "first_name", @class = "form-control input-sm ", @placeholder = "Project Name" }) 
  3. /*---here, model object continuing---*/
And controller actionresult.
  1. [HttpPost]  
  2.         public ActionResult GetProjectByID(int projectid)  
  3.         {             
  4.             PartnerBIL objPartnerBIL = new PartnerBIL();  
  5.             PartnerProjectVM partnerProjectVM = new PartnerProjectVM();  
  6.         var PartnerProjectBL = objPartnerBIL.GetProjectByID(projectid) as PartnerProjectBL;  
  7.             partnerProjectVM.idPartnerProject = PartnerProjectBL.idPartnerProject;  
  8.             partnerProjectVM.ProjectName = PartnerProjectBL.ProjectName;  
  9.             partnerProjectVM.ProjectDescription = PartnerProjectBL.ProjectDescription;  
  10.             partnerProjectVM.ProjectType = PartnerProjectBL.ProjectType;  
  11.             partnerProjectVM.Status = PartnerProjectBL.Status;  
  12.             partnerProjectVM.CompletionYear = PartnerProjectBL.CompletionYear;  
  13.             partnerProjectVM.ProjectLocation = PartnerProjectBL.ProjectLocation;  
  14.             partnerProjectVM.ClientName = PartnerProjectBL.ClientName;  
  15.             return View("PremiumUserRegProjects", partnerProjectVM);  
  16.         } 
 Please help me...

Answers (5)