Trying to create a disabled textbox if the attribute [Editable(false)]
is present on a property in the model.
public static IHtmlString SmartTextBox(this HtmlHelper helper, string content)
{
string htmlString = String.Format("<input type="text">{0}</input>", content);
return new HtmlString(htmlString);
}
Model:
public class User
{
public int Age { get; set; }
[Editable(false)]
public string Name { get; set; }
}
Is there anyway to check the model here and then add the disabled attribute to the input element if it's been disabled?
Here's a helper I wrote that adds an '*' to a label if the model property is marked as required. ModelMetaData has an IsReadonly property to might be able to leverage. You should be able to make the correct substitutions to make the changes for a textbox.