I work on asp.net MVC . I need to update last working date
based on request no when value 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 include request no and last working date .
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; }
}
//post
[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>