TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
2.1k
473.4k
Server Error/Application problem?
Aug 20 2020 6:32 AM
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;
// Route to CoursesRegistered
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);
}
// saving changes here.
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>
}
Reply
Answers (
3
)
JavaScript is not playing nice with boolean false
Publish .NET Core to Azure container registry