有這個類:無法從在.NET核心雙值Web表單價值
public class ClientViewModel
{
public long PKID { get; set; }
[Required]
public string Name { get; set; }
public string Unit { get; set; }
public string StreetNumber { get; set; }
public string Street { get; set; }
public string Suburb { get; set; }
public string State { get; set; }
public string PostCode { get; set; }
public string Country { get; set; }
public string DT_RowId { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
public bool IsActive { get; set; }
}
而這種代碼的Razor視圖:
<form method="post" asp-controller="Clients" asp-action="Edit">
<input asp-for="PKID" type="hidden" />
<div class="portlet-body">
<div class="row">
<div class="form-group col-md-2">
<label asp-for="Name">Name:</label>
<input class="form-control input-sm" type="text" placeholder="Name" asp-for="Name">
<span class="help-block has-error" asp-validation-for="Name"></span>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="row physical-row default-row">
<div class="col-md-2">
<label class="control-label">Unit</label>
@Html.TextBoxFor(model => model.Unit, new {placeholder = "Unit", id = "physicalLocationUnit", @class = "form-control input-sm"})
</div>
<div class="col-md-4">
<label class="control-label">Street</label>
@Html.TextBoxFor(model => model.Street, new {placeholder = "PhysicalAddress", id = "physicalLocation", onfocus = "physicalinitialize()", @class = "form-control input-sm"})
</div>
<div class="col-md-2 postcode-box">
<label class="control-label">Post Code</label>
<div>
<input type="text"
tabindex="-1"
class="form-control input-sm" />
</div>
</div>
<div class="col-md-2 lattitude-box">
<label class="control-label" asp-for="Latitude">Latitude</label>
<div>
<input type="text"
tabindex="-1"
class="form-control input-sm" asp-for="Latitude" />
</div>
</div>
<div class="col-md-2 longitude-box">
<label class="control-label" asp-for="Longitude">Longitude</label>
<div>
<input type="text"
tabindex="-1"
class="form-control input-sm" asp-for="Longitude" />
</div>
</div>
</div>
</div>
<div class="form-actions">
<div class="col-md-offset-6 col-md-6">
<button type="submit" class="btn green">Save</button>
<a asp-controller="Clients" asp-action="WorkManage" asp-route-id="@Model.PKID" class="btn green">Add Work</a>
</div>
</div>
</div>
</div>
</form>
在經度和緯度具有價值示例1.3
和2.45
但是當我嘗試調用控制器方法時,我只在這個變量中有0
值。我錯在哪裏? 乾杯!
當經度和緯度的值例如'1,3'和'2,45'它的作品。但是,當js驗證程序不能保存這個,因爲想看到'1.3'和'2.45' –