User-544325736 posted
Hello everyone,
I have a view with a submit button. It has multiple controls many of them are DropDownLists. In My Model class I only have certain properties that are required. My page will not submit unless all of my dropdownlists are picked it is making extra controls
required when I don’t want them. Any Idea why this is? Here is the code that I have. (Its making me have Software Type, Source, and Manufacturer)
//Model
[Required]
[Display(Name = "Part Book / Category")]
public string PartBook { get; set; }
//decimal
public string PartNextNumber { get; set; }
[Display(Name = "Today's Date")]
public DateTime DateEntered { get; set; }
[Required]
[Display(Name = "Entered By")]
public int EnteredBy { get; set; }
[Display(Name = "Software Type")]
public int SoftwareType { get; set; }
//unsure of this one ********************
[Display(Name = "Assembly Number")]
public string UsedOnAssembly { get; set; }
// INT OR BOOL ?
[Display(Name = "Global Part")]
public bool GlobalPart { get; set; }
//[Required]
public int Source { get; set; }
public int Manufacturer { get; set; }
[Display(Name = "Manufacturer Part Number")]
public string ManufacturerPartNumber { get; set; }
//View
t-danger" })
<div class="panel-body">
<div class="col-md-6 col-lg-6">
@* Change to DropDownList of ParkBooks *@
@*@onchange="location.href='"+
Url.Action("DoPartBookFunc","Parts", "parkbookDDL")+"'" *@
@Html.DropDownListFor(x => x.PartBook,
(IEnumerable<SelectListItem>) ViewBag.PartBookDDL,
"", new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.PartBook,
"", new { @class = "text-danger" })
</div>
<div class="form-group row">
<div class="col-md-3 col-lg-3">
@Html.LabelFor(x => x.SoftwareType,
htmlAttributes: new { @class = "control-label" })
</div>
<div class="col-md-6 col-lg-6">
@Html.DropDownListFor(x => x.SoftwareType,
(IEnumerable<SelectListItem>)ViewBag.SoftwareTypeDDL,
"", new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.SoftwareType, "",
new { @class = "text-danger" })
</div>
<div class="form-group row">
<div class="col-md-3 col-lg-3">
@Html.LabelFor(x => x.Source,
htmlAttributes: new { @class = "control-label" })
</div>
<div class="col-md-9 col-lg-9">
@Html.DropDownListFor(x => x.Source,
(IEnumerable<SelectListItem>) ViewBag.SourceDDL,
"", new { @class="form-control" })
@Html.ValidationMessageFor(x => x.Source,
"", new { @class = "text-danger" })
</div>
</div>
<div class="form-group row">
<div class="col-md-3 col-lg-3">
@Html.LabelFor(x => x.Manufacturer,
htmlAttributes: new { @class = "control-label" })
</div>
<div class="col-md-6 col-lg-6">
@Html.DropDownListFor(x => x.Manufacturer,
(IEnumerable<SelectListItem>)ViewBag.ManufacturerDDL,
"", new { @class="form-control" })
@Html.ValidationMessageFor(x => x.Manufacturer,
"", new { @class = "text-danger" })