CheckBoxList scroll bar

2020-08-10 06:06发布

问题:

Is there a way to let CheckBoxList to have scroll bars without using styles, Why ListBox support Rows propperty, and CheckBoxList does not support it.

Thanks

回答1:

It's not possible without using css, because a CheckBoxList is not an actual thing in HTML. It renders as a table with your checkboxes and labels in different cells.

The ListBox, however, renders as an HTML select element which has support for a size property that sets the number of rows to display before showing scroll bars.

The problem is that ASP.NET abstracts these differences away in how you deal with them on the server with its controls. As you have found, this can lead to confusing results when they render in the browser if you are not familiar with the HTML they produce.



回答2:

That is not possible. You have to use a Div around with overflow:scroll.

<DIV style="OVERFLOW-Y:scroll; WIDTH:600px; HEIGHT:500px">
</DIV>


标签: asp.net