-
-
Save andreabalducci/4317384 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IHtmlString SkinnedTextBoxFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, InputStyles styles = InputStyles.Normal, int size = 0) | |
{ | |
var cssClasses = BuildClasses(styles, "input"); | |
IDictionary<string, object> attrs = new Dictionary<string, object>(); | |
attrs["class"] = cssClasses; | |
if (size > 0) | |
attrs["size"] = size; | |
string format = null; | |
if (typeof (DateTime).IsAssignableFrom(expression.ReturnType)) | |
{ | |
attrs["type"] = "date"; | |
format = "{0:yyyy-MM-dd}"; | |
} | |
else if (typeof (TimeSpan).IsAssignableFrom(expression.ReturnType)) | |
{ | |
attrs["type"] = "time"; | |
format = "{0:hh':'mm}"; | |
} | |
return html.TextBoxFor(expression, format, attrs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment