My controller:
[HttpGet]
public ActionResult AddEstablishment()
{
return View("AddEstablishment",new EstablishmentModel());
}
My model:
public class EstablishmentModel
{
[Display(Name = "Establishment ID")]
public Guid EstablishmentId { get; set; }
.............
My AddEstablishment View:
@Html.TextBoxFor(x => x.EstablishmentId, new { @id = "inputEstGuid", @class = "input input-xlarge", @placeholder = "5C3B1CBC-2574-4E2A-A9FA-A8CA0041AB86" })
Result:
My textbox is prepopulating with the Guid default value
00000000-0000-0000-0000-000000000000
How can i avoid it?
Please note there are obvious reasons why I'm passing an instance of the model to the view.
Shouldn't this work?
public Guid? EstablishmentId { get; set; }
Just ensure that the value is null when you initially display your view.