Моя проблема: я понятия не имею, как написать метод CopyAddress
.
Я хочу заполнить StreetName
, нажмите кнопку, чтобы заполнить CorespondenceStreetName
автоматически.
Я использую:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<Address> Addresses { get; set; }
}
и имеют Address
класс модели:
public class Address
{
public int Id { get; set; }
public string StreetName { get; set; }
public string CorespondenceStreetName { get; set; }
}
и вид:
@model CRM.Models.Address
@{
ViewBag.Title = "Edit";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("Edit", "Address"))
{
@Html.AntiForgeryToken()
<div class="container">
@Html.HiddenFor(model => model.Id)
<div class="form-group">
@Html.LabelFor(model => model.StreetName, htmlAttributes: new {@class = "control-label"})
@Html.EditorFor(model => model.StreetName, new {htmlAttributes = new {@class = "form-control"}})
</div>
<a type="button" class="btn" href="@Url.Action("CopyAddress", "Address")">
<span>Copy from Main</span>
</a>
<div class="form-group">
@Html.LabelFor(model => model.CorespondenceStreetName , htmlAttributes: new {@class = "control-label"})
@Html.EditorFor(model => model.CorespondenceStreetName , new {htmlAttributes = new {@class = "form-control"}})
</div>
</div>