Ich verwende ein ASP.NET MVC-Projekt, das mit Entity Framework in Visual Studio 2017 erstellt wurde. Ich habe eine create-Ansicht für einen Angestellten-Controller, wo ein Benutzer Inventardaten eingeben kann . Ich möchte, dass das Benutzer-ID-Feld automatisch Daten aus Active Directory auffüllt. Wie implementiere ich ein Keypress- oder Tab-Out- oder Field-Change-Event, wenn der Benutzername eingegeben wird, so dass ein Lookup ausgelöst wird und bestimmte Felder mit relevanten Daten ausgefüllt werden?Automatisches Auffüllen von Feldern basierend auf einem einzelnen Feld auf Tab Out oder Keypress
Hier ist eine Idee von dem, was an Ich suche nach:
Hier einige der CSHTML als Referenz:
<div class="form-horizontal">
<h4>Employee</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.OfficeId, "Office", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("OfficeId", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.OfficeId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.username, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.username, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.username, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.FullName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FullName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FullName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.email, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.email, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.email, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.phone, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.phone, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.phone, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EquipId, "Equipment", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("EquipId", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.EquipId, "", new { @class = "text-danger" })
</div>
</div>
ich mit Ajax nicht vertraut bin und Ich weiß nur ein bisschen Javascript, ich würde eher versuchen, den Code zu C# zu enthalten, obwohl der gesamte Active Directory-Code bereits geschrieben wurde.
Könnte ich einfach eine "Lookup" -Schaltfläche neben dem Feld "User ID" hinzufügen, damit sie auf diese klicken, um sie zu füllen? Wenn das so ist, wie?