gpt4 book ai didi

css - ASP.NET MVC 控件和 CSS

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

我正在尝试在我的 html.dropdownlist 上使用常规 html 选择列表 css 应用 css。任何人都可以告诉我如何去做这件事以及我在哪里做错了

这就是我现在拥有的..

<div id="container">
Months &nbsp; <%=Html.DropDownList("dllMonths", new SelectList(new List<string>() { "January",
"Feburary", "March", "April", "June", "July", "August", "September", "October", "November", "December"}, ViewData["Month"]), new { onchange = "this.form.submit();" })%>

Events &nbsp;<%=Html.DropDownList("dllEvents", new SelectList(new List<string>() { "Camp Events",
"Weekly Events", "All Events"}, ViewData["Event"]), new { onchange = "this.form.submit();" })%>

</div>

这是我要应用的 css http://www.emblematiq.com/projects/niceforms/demo/

最佳答案

将您使用匿名对象设置 html 属性的代码部分更改为:

new { onchange = "this.form.submit();", @class="selectlist" }

@ 符号允许您使用作为保留字的属性名称。如果您想要内联样式,您也可以添加 style=""(但您可能不需要)。

此外,您不需要更新 SelectList,Html.DropDownList() 有一个重载,可让您传递相同的值。

关于css - ASP.NET MVC 控件和 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/452075/

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