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
vineet sharma
NA
22
22k
how to call controller from JavaScript in c#
Apr 28 2014 2:23 AM
how to call a controller function in javascript using c#?
my code
Controller:
[HttpGet]
public ActionResult checkidfornewuser(int eid)
{
int count = 0;
//int id = Convert.ToInt32(eid);
Models.emloyee_leaveDataContext employee = new Models.emloyee_leaveDataContext();
var result=from t in employee.GetTable<Models.employeeinfo>()
where t.id==eid
select t.name;
foreach(var tt in result)
{
count++;
}
if(count>0)
{
return Json("Invalid", JsonRequestBehavior.AllowGet);
}
else
{
return Json("valid", JsonRequestBehavior.AllowGet);
}
}
java script code
$("#button1").click(function () {
var id = document.getElementById(model.id);
$.getJSON('/Home/checkidfornewuser/'+id, null, displaydata)
{
return true;
}
function displaydata(data)
{
alert(data.valid);
}
});
thanks in advance
Reply
Answers (
1
)
Timing limit in Activation mail in User registration
How to bind images to drop down list from database ?