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
Sbonga Mathobela
NA
68
7.5k
Working with web Method and ajax
Jun 6 2017 5:53 AM
Hi
I have the following on my Calender.aspx code behind:
[WebMethod]
public static void saveTask(string DATE, int IDEVENT)
{
using (ProjectManagementEntities db = new ProjectManagementEntities())
{
var updateTask = db.tb_Task.FirstOrDefault(x => x.Id == IDEVENT);
updateTask.StartDate = Convert.ToDateTime(DATE);
db.SaveChanges();
}
}
and the following script:
function saveTask(theDATE, theIDEVENT) {
$.ajax({
type: "POST",
url: "Calender.aspx/saveTask",
data: JSON.stringify({ date : theDATE, id : theIDEVENT }),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert('Task Updated Successfully.');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Error");
}
});
};
The problem is I can't debug the webMethod saveTask, i put a breakpoint but t doesn't even hit the page. It seem the script does not hit the webMethod so can you please assist.
Thanks.
Reply
Answers (
3
)
server error after hosting
Bind Dynamic navigation bars on MVC Partial Views