0
我正在使用Visual Studio 2017中使用實體框架創建的ASP.NET MVC項目。我有一個Employees控制器的創建視圖,用戶可以在其中輸入清單數據。我想讓用戶ID字段自動填充Active Directory中的數據。如何在輸入用戶名時實施按鍵或製表符或字段更改事件,以便觸發查找並返回並填充具有相關數據的特定字段?在Tab Out或Keypress上基於單個字段自動填充字段
這裏是什麼,我看着一個想法:
下面是一些CSHTML作爲參考:
<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>
我不熟悉的Ajax和我只知道一點點javascript,但我寧願嘗試將代碼包含到C#中,因爲所有與Active Directory相關的代碼都已寫入。
我可以在用戶ID字段旁邊添加一個「查找」按鈕,讓他們單擊它來填充?如果是這樣如何?