I am fairly new to MVC, so this may be an easy answer, however, since no other datatypes apparently work like this, I cannot find anything on Google.
I have a model that has a field of type dbgeography. When I use the @Html.EditiorFor() helper it adds about a dozen different fields. My goal is to only ask the user for latitude and longitude, and use the static CoordinateSystemID of 4326. None of the other fields are relevant to the geography objects my users will be creating.
My model is
namespace MM.Models
{
using System;
using System.Collections.Generic;
public partial class Projects
{
public int ProjectID { get; set; }
public System.Data.Entity.Spatial.DbGeography BeginPosition { get; set; }
public System.Data.Entity.Spatial.DbGeography EndPosition { get; set; }
}
}
My view (just scaffolded) looks like:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Projects</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ProjectID)
<div class="form-group">
@Html.LabelFor(model => model.BeginPosition, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.BeginPosition, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.BeginPosition, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EndPosition, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.EndPosition, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.EndPosition, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
And the result is : Screenshot
Any help would be appreciated.