开发者

Wrapping a collection of checkboxes into a textarea MVC 3

开发者 https://www.devze.com 2023-03-08 10:44 出处:网络
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

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.

0

精彩评论

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