开发者

asp.net mvc and valid xhtml?

开发者 https://www.devze.com 2022-12-19 02:10 出处:网络
For some reason an html helper is outputting this html which doesnt validate. the validator tells me There is no attribute \"Length\"

For some reason an html helper is outputting this html which doesnt validate.

the validator tells me

There is no attribute "Length"

<%= Html.CheckBox("Medicamentos", Model.Medicamentos) %>

is outputting

<input type="checkbox" value="true" name="Medicamentos" id="Medicamentos" checked="checked" length="4"&开发者_C百科gt;


I assume that it's matching the signature that takes a string and an object since I don't know what Model.Medicamentos is. In that case it takes the properties of the object and turns them into attributes on the element. I suspect that you simply want to use the Checked attribute on the Model property specified as the default value of the checkbox, i.e.,

<%= Html.CheckBox( "Medicamentos", Model.Medicamentos.Checked ) %>

In, which case, assuming that Checked is boolean it will match the correct method signature on the helper extension.

0

精彩评论

暂无评论...
验证码 换一张
取 消