Hi Team
I have a routing problem, i have configured my routing well, but some how i am encountering a problem. This is my logic below;
-
- routes.MapRoute(
- name:"CoursesRegistration",
- url:"courses-enrolled-for/",
- defaults: new {controller="Home", action = "CoursesRegistration", url = UrlParameter.Optional}
-
- );
-
- [HttpPost]
- public ActionResult CoursesRegistration( eNtsaRegCourses model)
- {
- if(ModelState.IsValid)
- {
- try
- {
- cb.SaveChanges();
- return Json(new { success = true });
- }catch(Exception ex)
- {
- ModelState.AddModelError("", ex.Message);
- }
- }
- return PartialView("CoursesRegistration", model);
- }
-
- static void SaveChanges(eNtsaCourses model)
- {
- }
- @using (Html.BeginForm("CreateCoursesRegistration", "Home", FormMethod.Post, new { id = "createCourseForm", @class = "form-horizontal" }))
- {
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
- <a href="@Url.Action("CoursesRegistration", "Home")" class="btn btn-large btn-success", onclick="$('#exampleModal').modal('show')">Create Courses</a>
- <script type="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;
- }
- </script>
- </div>
- }