You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class UserVM
{
public IList<UserRoleVM> PreselectedUserRoles { get; set; }
public IList<UserRoleVM> AllUserRoles { get; set; }
}
public class UserRoleVM
{
public int Id {get; set;}
public string Name {get; set;}
public bool IsSelected {get; set;}
}
Year, i implement two ways to pass preselected items, but only because none of them works.
After that i calls:
@Html.CheckBoxListFor(user => user.PostedUserRoles.UserRolesIds,
user => user.AllUserRoles,
x => x.Id,
x => x.Name,
ur => ur.IsSelected, // error here
new { @class = "user-roles" })
And got error
CS1061: 'UserVM' does not contain a definition for 'IsSelected' and no extension method 'IsSelected' accepting a first argument of type 'UserVM' could be found (are you missing a using directive or an assembly reference?)
OK, i try:
@Html.CheckBoxListFor(user => user.PostedUserRoles.UserRolesIds,
user => user.AllUserRoles,
x => x.Id,
x => x.Name,
user => user.PreselectedUserRoles, // error here
new { @class = "user-roles" })
CS1061: 'UserRoleVM' does not contain a definition for 'PreselectedUserRoles' and no extension method 'PreselectedUserRoles' accepting a first argument of type 'UserRoleVM' could be found (are you missing a using directive or an assembly reference?)
But when i get rid of 6th param width custom HTML code - all works fine.
// OK
@Html.CheckBoxListFor(user => user.PostedUserRoles.UserRolesIds,
user => user.AllUserRoles,
x => x.Id,
x => x.Name,
user => user.PreselectedUserRoles
// OK
@Html.CheckBoxListFor(user => user.PostedUserRoles.UserRolesIds,
user => user.AllUserRoles,
x => x.Id,
x => x.Name,
ur => ur.IsSelected)
How can i use custom html tags with MvcCheckBoxList?
The text was updated successfully, but these errors were encountered:
Sorry for the late reply, I'll post it here in case someone else has the same issue.
Unfortunately, those overload parameters have a different meaning depending on number parameters used. I believe custom html tags would only work using full example:
var htmlListInfo = new HtmlListInfo(HtmlTag.vertical_columns, 2, new { @class="styled_list" };
@Html.CheckBoxListFor(x => x.PostedCities.CityIDs,
x => x.AvailableCities,
x => x.Id,
x => x.Name,
x => x.SelectedCities,
new { @class="styled_checkbox" }, // additional html attributes (for each checkbox and label)
htmlListInfo), // formatting
new[] {"3", "5", "7"}, // disabled values
x => x.Tags) // html tags from database
I have two simple classes:
Year, i implement two ways to pass preselected items, but only because none of them works.
After that i calls:
And got error
OK, i try:
But when i get rid of 6th param width custom HTML code - all works fine.
How can i use custom html tags with MvcCheckBoxList?
The text was updated successfully, but these errors were encountered: