To Check if Request comes from ajax in Controller use the following :
public JsonResult GetEmployeeName( int id)
{
if (Request.IsAjaxRequest())
{
if (Request.IsAjaxRequest())
{
}
or you can set [AjaxOnly] annotation to set action in controller works only for ajax
request.
[AjaxOnly]
public JsonResult GetEmployeeName( int id)
{
var result = Json(GetEmployeeByID(id), JsonRequestBehavior.AllowGet);
public JsonResult GetEmployeeName( int id)
{
var result = Json(GetEmployeeByID(id), JsonRequestBehavior.AllowGet);
return result ;
}
}
EmoticonEmoticon