0

I was trying to implement a 'CheckboxListFor' method but am having some issues with formating in which the text for the checkbox does not align on the side of the checkbox but instead is below the checkbox. Here is what it looks like

Code in View:

     @{ 
         var htmlListInfo = new HtmlListInfo(HtmlTag.table, 4, null, 
                                             TextLayout.Default, TemplateIsUsed.No);
     }


      @Html.CheckBoxListFor(model => model.KeywordIDs,
                                     model => model.Keywords,
                                     model => model.KeywordId,
                                     model => model.Name,
                                     model => model.SelectedKeywords,
                                     htmlListInfo
       );

Any insight would be greatly appreciated.

2
  • 1
    Hello, Please refer this link mvccbl.com/…. I doubt the issue is with HtmlTag.table it should be (HtmlTag.vertical_columns Commented Sep 2, 2013 at 5:29
  • That's where I pull my info from to begin with and using the verical_columns gives me the same problem except that the columns are compressed even further instead of evenly spaced. Commented Sep 2, 2013 at 5:38

1 Answer 1

3

Ok gr8.. Minor change. Try this code.

have to apply css to fix it.

<style type="text/css">
    label
    {
        display: inline-block !important;
        padding: 5px !important;
    }
</style>
@{ 

    var htmlListInfo = new HtmlListInfo(HtmlTag.table, 4, null, TextLayout.Default, TemplateIsUsed.No);

    @Html.CheckBoxListFor(model => model.PostedCities.CityIDs,
                      model => model.AvailableCities,
                      city => city.Id,
                      city => city.Name,
                      model => model.SelectedCities,
                      htmlListInfo)
}

let me know your comments.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that works. Didn't know about !important and that will help in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.