I'm rendering a collection of checkboxes (over 20) onto an MVC 3 Razor view and rather than make users scroll through a long page I'd like to put them into a scrollable display. Textarea seemed like the obvious choice, but I'm having trouble wrapping the collection around a textarea. To make things a little m开发者_高级运维ore tricky, the checkboxes are dynamically iterated and created, so I basically need to find out how to wrap this iteration into a scrollable area:
if (setting.DataType=="Multi-Value List")
{
string result = "";
<br /><b>@setting.Label</b><br />
foreach (var MultiListSetting in Model.Datasource.Where(c=>c.listId==setting.Datasource))
{
if (setting.Value != null)
{
@Html.CheckBox("MultiListsetting", setting.Value.Contains(MultiListSetting.value) ? true : false, new {ID=@MultiListSetting.value}) @MultiListSetting.value;<br />
}
else
{
@Html.CheckBox("MultiListsetting", false, new { ID = @MultiListSetting.value }) @MultiListSetting.value;<br />
}
}
<br />
@Html.Hidden("SetViewModel[" + i + "].Value", setting.Value, new { ID = "MultiValueListReturn" })
@Html.Hidden("SetViewModel[" + i + "].ID", setting.ID)
i += 1;
}
I'm just finding out about scollable areas in HTML and CSS, so maybe I'll come across something there. Thank you!
You should put them in a <div>
with overflow: scroll
.
精彩评论