Abhilash J A

Abhilash J A

  • 533
  • 2.4k
  • 598.2k

Issue - ajax refresh page after submit MVC.

Mar 13 2017 9:22 PM
Hello everyone,
 
I am working on MVC 5, there is registration page look like, 
  1. @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "submitBasicUserReg" }))  
  2. {  
  3.   
  4.   @Html.TextBoxFor(model => model.listPartnerVM.LoginName, new { @id = "idemail", @class = "form-control input-sm ", @placeholder = "E-mail", @maxlength = "50" })  
  5.   
  6.                                                         @Html.PasswordFor(model => model.listPartnerVM.Password, new { @id = "password", @class = "form-control input-sm ", @placeholder = "Password", @maxlength = "20" })  
  7.   
  8.                                                         @Html.PasswordFor(model => model.listPartnerVM.ConfirmPassword, new { @id = "password", @class = "form-control input-sm ", @placeholder = "Confirm Password", @maxlength = "20" })  
  9.   
  10. <input type="submit" value="Submit" class="btn reg-btn btn-block">  

  11.   
  12. }  
 Ajax, 
  1. $("#submitBasicUserReg").submit(function (e) {  
  2.     var formData = new FormData(this);  
  3.   
  4.     $.ajax({        
  5.         url: "/UserRegister/GetBasicUserReg",  
  6.         type: "POST",  
  7.         data: $('form').serialize(),  
  8.         success: function (result) {  
  9.              
  10.             $("#divSavedMessage").html(result);  
  11.         },  
  12.         error: function (result) {  
  13.   
  14.         }  
  15.     });  
  16.     e.preventDefault();  
  17. });  
 Controller, 
  1. [HttpPost]  
  2.         public ActionResult GetBasicUserReg(PartnersVM partnersVM)  
  3.         {  
  4.                 PartnerBL partnerBL = new PartnerBL();  
  5.                 PartnerBIL partnerBIL = new PartnerBIL();               
  6.                 partnerBL.LoginName = partnersVM.listPartnerVM.LoginName;                 
  7.                 partnerBL.Password = partnersVM.listPartnerVM.Password;  
  8.                 partnerBIL.Partner_AddUpdate(partnerBL);               
  9.           
  10.             return View("_savedSuccessMessageBox");  
  11.         }  
The problem is, after saving data and redirect to the same registration page then, texboxes are carrying saved previous value. How can I refresh the page as new entry? 
 
Please help me... 
 

Answers (1)