【发布时间】:2020-06-13 03:04:59
【问题描述】:
您好,我有一个使用电子邮件地址值作为搜索字段的表单,当系统中存在电子邮件地址时,我想填充表单。
我创建了此操作以通过电子邮件地址搜索
public async Task<IActionResult> GetContactByEmailID(string emailID)
{
if (emailID == null)
{
return NotFound();
}
var Contacts = await ContactsService.GetContactsByEmailID(emailID);
if (Contacts == null)
{
return NotFound();
}
var ContactsDetail = Mapper.Map<Contact>(Contacts);
return View(ContactsDetail);
}
我需要有关如何在单击按钮时调用上述操作的帮助,如果存在,我想在名称文本框中显示与电子邮件地址关联的联系人姓名
<div class="col-sm-6">
<label for="EmailAddress" class="col-6 form-control-label">Email</label>
<input asp-for="EmailAddress" type="email" id="emailaddress" >
<button class="btn" role="button">Search</button>
</div>
以下是我要显示所选联系人姓名的地方
<form>
<div class="col-sm-5 m-b">
<label for="Name" class="col-sm-10 form-control-label required">Full Name</label>
<input asp-for="Name" type="text" class="form-control form-control" id="Name" placeholder="">
<span asp-validation-for="Name" class="text-danger" />
</div>
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-core