I want when click to submit button,
send form to post method.
thanks for your help.
html code
<form method="post" class="form-horizontal editor-horizontal">
<div class="form-group">
<div class="col-sm-9">
<a href="#" id="name" data-type="text"
data-pk="1" data-placeholder="Required"
data-title="نام خود را وارد کنید">@Model.Information.Doctor.Name</a>
</div>
<label class="col-sm-3 control-label">نام</label>
</div>
<div class="form-group">
<div class="col-sm-9">
<a data-pk="1" data-placeholder="Required" data-placement="left"
data-title="نام خانوادگی خود را وارد کنید " data-type="text"
href="#" id="family" >@Model.Information.Doctor.Family</a>
</div>
<label class="col-sm-3 control-label">نام خانوادگی </label>
</div>
<button type="submit" class="btn btn-primary" >تایید</button>/>
</form>
this is my method post
public IActionResult OnPost(EditDoctorViewModel command)
{
var user= _service.EditDoctor(command);
return Page();
}
If you want to send form to post method, you should use input
in your view, Here is my code:
model
public class EditDoctorViewModel
{
public Information information { get; set; }
}
public class Information
{
public Doctor Doctor { get; set; }
}
public class Doctor
{
public string Name { get; set; }
public string Family { get; set; }
}
veiw
<form method="post" class="form-horizontal editor-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label" >نام</label>
<input type="text" asp-for="command.information.Doctor.Name" />
</div>
<div class="form-group">
<label class="col-sm-3 control-label" >نام خانوادگی </label>
<input type="text" asp-for="command.information.Doctor.Family" />
</div>
<button type="submit" class="btn btn-primary">تایید</button>
</form>
controller
public EditDoctorViewModel command { get; set; }
public Information Information { get; set; }
public IActionResult OnPost([FromForm]EditDoctorViewModel command)
{
//var user = _service.EditDoctor(command);
return Page();
}