i want to execute a controller action method soon after entering the data in a textbox glgroupcode
the action method takes glgroupcode textbox value as a parameter and result should get populated in another textbox .
the below is my jquery code and action method
$('#GLGroupCode').on('keypress ', function (event) {
alert("s");
$.ajax({ url: "/GLMaster/TextChanged", type: "GET", data: { text: $('#GLGroupCode').val() }, dataType: 'json', success: function (result) {
$('#txtSearch1').val(result);
}
});
});
@Html.TextBoxFor(model => model.GLGroupCode)
@Html.ValidationMessageFor(model => model.GLGroupCode )
@Html.LabelFor(model => model.GLGroupName)
@Html.TextBoxFor(model => model.GLGroupName, new { id = "txtSearch1" })
@Html.ValidationMessageFor(model => model.GLGroupName)
public JsonResult TextChanged(string GLGroupCode)
{
var subGroups = from p in db.tblGLGroups where p.GroupCode == GLGroupCode select p.GroupName;
return Json(subGroups, JsonRequestBehavior.AllowGet);
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
swsh hussainPosted Nov 14, 2015, 5:12 AM
Ravi PatelPosted Nov 14, 2015, 4:39 AM