如何在不使用提交按钮点击的情况下更改值上次工作日期输入文本?

How I Can change value last working date input text without using submit button click?

提问人:ahmed abdelaziz 提问时间:11/5/2023 最后编辑:ahmed abdelaziz 更新时间:11/5/2023 访问量:53

问:

我在 asp.net MVC 上工作。我需要更新上一个工作日期

基于请求 no when 值 Last working date changed 。

我需要使用ajax jQuery来做到这一点

Web API,我将使用 jQuery ajax 调用它Resignation/Edit

辞职是控制者,编辑是行动,我会通过的

对象编辑操作结果包括请求号和最后工作日期。

我的代码如下:

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>
javascript jquery ajax asp.net-web-api

评论

0赞 Yong Shun 11/7/2023
我不明白你的问题。像侦听器/观察者这样的东西,当数据库中的“最后工作日期”发生变化时,它会自动更新前端?
0赞 derloopkat 11/7/2023
请改写您的问题。你的目标是什么,你面临的问题是什么?

答: 暂无答案