Reputation: 2924
I have dowloaded and examined the Microsoft's MVC source codes from CodePlex. According to the source code the class definitions is as follows:
namespace System.Web.Mvc
{
public class SelectListItem
{
/// <summary>
/// Gets or sets a value that indicates whether this <see cref="SelectListItem"/> is disabled.
/// </summary>
public bool Disabled { get; set; }
/// <summary>
/// Represents the optgroup HTML element this item is wrapped into.
/// In a select list, multiple groups with the same name are supported.
/// They are compared with reference equality.
/// </summary>
public SelectListGroup Group { get; set; }
public bool Selected { get; set; }
public string Text { get; set; }
public string Value { get; set; }
}
}
But when I write the following code
List<System.Web.Mvc.SelectListItem> statuses = (from s in DataContext.OfferStatuses
select new System.Web.Mvc.SelectListItem
{
Value = s.Id.ToString(),
Text = s.Code,
}).ToList();
in the class property definitions I can not see the "Disabled" property. Also when I iterate through the statuses collection I still can not see the property either.
Why can not I see some of the properties that are defined public?
Upvotes: 0
Views: 1012
Reputation: 93424
When you look at the code in codeplex, you're looking at the CURRENT code, which is MVC 5.x. You're using MVC4, which is not the current code, so the code you see is not the code you're using.
In fact, the Disabled property was added to MVC5, and not part of MVC4. This is why you cannot access it in your MVC4 code. You can see this by going to the codeplex site, and browsing the code in the web viewer, then view previous versions you will see that it did not exist in previous versions.
You can also see by looking at the previous version in the MSDN documentation:
MVC5 documentation: http://msdn.microsoft.com/en-us/library/system.web.mvc.selectlistitem(v=vs.118).aspx
MVC4 Documentation http://msdn.microsoft.com/en-us/library/system.web.mvc.selectlistitem(v=vs.108).aspx
Upvotes: 1