Select list enum tag helper.

If you want to have a select list in a web page which is based on all the values in an enum then you can use the built in function “Html.GetEnumSelectList” with a tag helper.

public enum PushType
<div class="row">
	<div class="col-sm-2">
		<label asp-for="@Model.Data.Type" class="control-label text-left"></label>
	<div class="col-sm-10">
		<select asp-for="@Model.Data.Type" asp-items="Html.GetEnumSelectList<PushType>()" class="form-control" required="required">
			<option selected="selected" value="" disabled>--Please Select--</option>
		<div class="help-block with-errors"></div>

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *