【发布时间】:2021-08-09 17:28:51
【问题描述】:
我知道这个问题可能已经在这个网站上,但是我的方法中有一些不同的东西,因为我使用了@Html.EditFor 和@Html.DropDownList。 所以我有一个下拉列表,当我在那里选择 ID 时,我想从数据库中检索一些信息,然后在当前表单中填充一些字段。我知道我应该使用JS,但我不知道如何。
查看:
@model TestApp.Dtos.InsertDto
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="col-md-9">
@Html.DropDownListFor(model => model.Category, new SelectList(Model.ListOfCategory, "Text", "Text"), "-- Please select --", htmlAttributes: new { @class = "form-control"});
</div>
<div class="col-md-9">
@Html.EditFor(model => model.Car, new{htmlAttributes = new { @class = "form-control" }});
</div>
@*And then the form continues with other fields and after that the submit button *@
}
【问题讨论】:
标签: javascript asp.net asp.net-core razor