Last post Sep 28, 2019 04:06 PM by bruce (sqlwork.com)
Member
5 Points
46 Posts
Sep 28, 2019 02:53 AM|kvic|LINK
<label asp-for="Market" class="control-label"></label> <div class="input-group mb-3"> <div class="input-group-prepend"> <a asp-controller="Markets" class="btn btn-outline-secondary" id="button-addon1">Add</a> </div> <select class="form-control" asp-items="ViewBag.Market"></select> <span asp-validation-for="Market" class="text-danger"></span> </div>
If I provide a option Value for the user to select a vlaue:
<select class="form-control" asp-items="ViewBag.Market"> <option>Select</option> </select>
The validation will not trip as the form will accept "Select" as the user value;
It would be great if the Data Annotations work with the select control but that doesn't happen:
[Display(Name = "Market", Description = "The Market Name.", Prompt = "Market Name", ShortName = "Market Name", Order = 1)] public string Market { get; set; }
I would like a way to trip the validation on the view before going to the server if the selection is Select?
All-Star
57864 Points
15493 Posts
Sep 28, 2019 04:06 PM|bruce (sqlwork.com)|LINK
Set value to blank and only the text to “Select” of the option.
Member
5 Points
46 Posts
<select class="form-control" asp-items="ViewBag.Market"></select>
Sep 28, 2019 02:53 AM|kvic|LINK
If I provide a option Value for the user to select a vlaue:
The validation will not trip as the form will accept "Select" as the user value;
It would be great if the Data Annotations work with the select control but that doesn't happen:
I would like a way to trip the validation on the view before going to the server if the selection is Select?
All-Star
57864 Points
15493 Posts
Re: <select class="form-control" asp-items="ViewBag.Market"></select>
Sep 28, 2019 04:06 PM|bruce (sqlwork.com)|LINK
Set value to blank and only the text to “Select” of the option.