我的模型中有一个可以为空的bool
public bool? Property { get; set; }
我通过EditorFor
@Html.EditorFor(model => model.Property)
如何将类form-control
添加到呈现的选择中?如何本地化字符串Not set
,True
和False
?或者更好的我如何用自定义字符串替换它们?
答案 0 :(得分:2)
<script type="text/javascript">
var newWin;
function newWindow()
{
newWin=window.open('http://www.google.co.in','_blank');
setTimeout(function(){newWin.close()}, 5000);
}
</script>
<button onclick="newWindow()">open Window</button>
答案 1 :(得分:1)
You can try with below code:
@Html.DropDownListFor(m => m.Property,
new List<SelectListItem>(){
new SelectListItem { Value = "False", Text = "False" },
new SelectListItem { Value = "True", Text = "True" }
},"Not set",new { @class = "form-control" })