문제

Well here I'm trying to add a Bootstrap class to the DropDownList generated by Razor, but it keeps giving me squigglies.

 @Html.DropDownList("NationalityId", String.Empty, new {@class="form-control"})

Any recommendation as to how I can get this to work.

도움이 되었습니까?

해결책

it works:

@Html.DropDownList("NationalityId",new List<SelectListItem>(), new {@class="form-control"})

Result html:

<select name="NationalityId" id="NationalityId" class="form-control"></select>

다른 팁

Try this one:

@Html.DropDownList( "NationalityId", null, new { @class = "form-control" } )

Another option:

@Html.DropDownList("NationalityId", Enumerable.Empty<SelectListItem>(),new {@class="form-control"})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top