gpt4 book ai didi

css - 我如何设计 MVC 5 下拉菜单以匹配 Bootstrap ?

转载 作者:行者123 更新时间:2023-11-28 10:34:12 25 4
gpt4 key购买 nike

这是我的代码,但我一辈子都想不出如何为这个人设计样式:

<div class="col-sm-4">

@Html.DropDownListFor(m => m.HousingType, new SelectList(new List<Object>
{
new { value = "Rent", text = "Rent"},
new { value = "Own", text = "Own"},
new { value = "Live with parents", text = "Live with parents"},
},
"value",
"text",
2
))

@Html.ValidationMessageFor(m => m.HousingType)
</div>

最佳答案

你只需要用这个替换你的 dropdownlistfor razor 代码:

@Html.DropDownListFor(m => m.HousingType, new SelectList(new List<Object>
{
new { value = "Rent", text = "Rent"},
new { value = "Own", text = "Own"},
new { value = "Live with parents", text = "Live with parents"},
},
"value",
"text",
2
), new { @class = "form-control" })

在使用 asp.net mvc HTML Helpers 时,引用重载总是好的。 This is the link for DropDownListFor Helper. Visual Studio 中的 Intellisense 还可以在您开始键入/编辑时为您提供帮助。

关于css - 我如何设计 MVC 5 下拉菜单以匹配 Bootstrap ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23401622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com