I am using asp.net mvc application. In my view page i have textbox like below code:
@Html.TextBoxFor(m => m.Id, new { @class = "form-control", @readonly = "readonly" })
Also, in form submit ajax post,
$('#btnSubmit').click(function(e)
{
$.ajax({
url: '/button/Button',
type: 'POST',
data: {Id:1},
});
});
My controller:
MasterM empcode = new MasterM();
[HttpGet]
public ActionResult Button()
{
var empcode = new MasterM();
return View(empcode);
}
[HttpPost]
public ActionResult Button(MasterM model)
{
ModelState.Clear();
if (!ModelState.IsValid)
{
return View(model);
}
return View(model);
}
after this form submit the value of the text box should change to new value (1). How can i achieve this in controller section itself. I know in ajax success we can manually update the element value but i want to achieve this in controller section and update model with new values.
Idis1is the POST method). If you want to update the textbox, then use javascript, or update the DOM with the view you have returned in the success callback