I work on asp.net MVC . I face issue I can’t change last working date based on RequestNo
.
without using button submit
meaning when last working date changed then call Edit action inside resignation controller without using submit button when value of input type text last working date changed
I need to using ajax jQuery to do that
Web API I will call it using jQuery ajax is Resignation/Edit
Resignation is controller and edit is action and I will pass object to Edit action result .
I need to do that without using form and I will depend on java script or jQuery
my code as below :
public class ResignationRequester
{
[Display(Name = "Request No")]
public int RequestNo { get; set; }
[Required]
[Display(Name = "Last Working Day: ")]
[DataType(DataType.Date, ErrorMessage = "Date only")]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime LastWorkingDate { get; set; }
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Edit(ResignationRequester req)
{
//UPDATE last working date based on Request No
}
@model HR.WorkforceRequisition.Models.ResignationRequester
@{
ViewBag.Title = "Details";
Layout = "~/Views/Shared/_LayoutResignation.cshtml";
}
<table style="border: 1px solid black;width:100%;">
<tr>
<td class="hover" style="width: 50%; font-weight: bold; padding-top: 10px;">
<div class="form-group hover">
@Html.LabelFor(model => model.RequestNo, htmlAttributes: new { @class = "control-label col-md-5" })
<div class="col-md-7" id="RequestNo">
@Model.RequestNo
</div>
</div>
</td>
</tr>
<tr>
<td class="hover" style="width: 50%; font-weight: bold; padding-top: 10px;">
<div class="form-group hover">
@Html.LabelFor(model => model.LastWorkingDate, htmlAttributes: new { @class = "control-label col-md-5" })
<div class="col-md-7">
@Html.EditorFor(model => model.LastWorkingDate, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
</td>
</tr>
</table>
</div>