I work on asp.net mvc . i face issue employee name display based on auto complete selection
and after select employee id from auto complete employee name display based on selection employee id
after click submit button create action fire and page load but employee name not display so
How to solve this issue please
full code details
@model HR.WorkforceRequisition.Models.ResignationRequester
@{
ViewBag.Title = "Create";
}
@using (Html.BeginForm("Create", "Resignation", FormMethod.Post, new { enctype = "multipart/form-data", @id = "mainform", style = "padding-top: 50px" }))
{
@Html.LabelFor(model => model.LineManager, htmlAttributes: new { @class = "control-label" })
*
@Html.EditorFor(model => model.LineManager, new { htmlAttributes = new { @class = "form-control", id = "txtLineManagerId" } })
@Html.Label("Line Manager Name", htmlAttributes: new { @class = "control-label" })

Mohammad HussainPosted Aug 28, 2023, 7:19 AM
Include a Hidden Field for Employee Name: Add a hidden input field in your form to store the selected employee name. This hidden field will hold the value of the selected employee name so that it can be posted back to the server during form submission.
Update the Autocomplete
selectCallback: Update theselectcallback of the autocomplete to set the value of the hidden input field (LineManagerNameHidden) along with the visible input field (LineManagerName).Populate the Employee Name on Page Load: In your server-side code, when rendering the page after form submission, you need to populate the employee name from the model data into the visible input field (
LineManagerName) and the hidden input field (LineManagerNameHidden).