Skip to content
Loading
    
  •                                           
  •                                         class="form-group row">  
  •                                             for="Content-Licence" class="col-sm-3 col-form-label">Content Licence  
  •                                             class="col-sm-5">  
  •                                               
  •                                               
  •                                           
  •                                         @using (Html.BeginForm("CreateCoursesRegistration", "Home", FormMethod.Post, new { id = "createCourseForm", @class = "form-horizontal" }))  
  •                                         {  
  •                                         class="modal-footer">  
  •                                             "button" class="btn btn-secondary" data-dismiss="modal">Cancel  
  •                                             "@Url.Action("CoursesRegistration", "Home")" class="btn btn-large btn-success", onclick="$('#exampleModal').modal('show')">Create Courses  
  •                                             "text/javascript">  
  •                                                 function createCourses() {  
  •                                                     $.ajax({  
  •                                                         url: "/Home/CoursesRegistration",  
  •                                                         data: $('#createCourseForm').serialize(),  
  •                                                         type: 'post',  
  •                                                         success: function (data) {  
  •                                                             if (data.Success) {  
  •                                                                 $("#exampleModal").modal('hide');  
  •                                                             } else {  
  •   
  •                                                             }  
  •   
  •                                                         },  
  •                                                         error: function (xhr, status) {  
  •   
  •                                                         }  
  •                                                          
  •                                                     });  
  •                                                     return false;  
  •                                                 }  
  •   
  •   
  •                                               
  •   
  •                                           
  •                                         }  
  •                                       
  •                                   
  •                               
  •  
    +2
  • +2
    Hi Sahoo
     
    I do get the point, you my point is currently mine is not saving from the db, once it does i can then use this similar example to call it via web api. at this point its still empty all records 
    +2
  • Varun Setia
    +1
    I think you are missing cb.SaveChanges()
    +1
  • +1
    No if you look closely, there is inside my try catch statement, its throwing Server/Error in Application
    +1
  • Ashutosh Gupta
    0
    this is seems to be problem "private eNtsaRegCourses cb = new eNtsaRegCourses();", this instance wil be created newly for each Http Request, hence use dependency injection to inject this "eNtsaRegCourses" from constructor..
     
    once the instance is created per scope then saving will have list of new courses which was added in different Post endpoints "cb.eNtsaCourse.Add(courses);"
    0
  • Laxmidhar Sahoo
    0
    Hi
     
    I think  it is web api and you should ajax call from the page .
     
    https://www.c-sharpcorner.com/article/call-asp-net-webapi-using-jquery/
     
    Thanks and regards 
    0
  • Varun Setia
    0
    Stack trace of exception would help. Can you share ?
    0
  • Farhan Ahmed
    -1
    https://stackoverflow.com/questions/20248365/twitter-bootstrap-modal-does-not-work-properly-when-implementing-in-asp-net-mvc
    https://forums.asp.net/t/2163108.aspx?Opening+Bootstrap+Modal+pop+up+from+controller
    https://www.codeproject.com/Questions/1226998/Modal-popup-close-button-is-not-working-in-MVC-pro 
    https://forums.asp.net/t/2161560.aspx?Bootstrap+modal+with+OnClick+button+not+working 
    -1
  • Asma Khalid
    -1
    You have not created Http Post method, you have created only http get method. Add following attribute on top of your method i.e.
    1. [Route("Home/CoursesRegistration")]    
    2. [HttpPost]  
    3. public ActionResult CoursesRegistration(eNtsaRegCourses model)   
    4. {  
    5. ..  
    6. } 
    Mark the answer as accepted if helpful.
     
    Thanks & Regards,
    Asma Khalid
     
    For more visit www.asmak9.com
    -1