Created
June 24, 2012 20:22
-
-
Save sniffdk/2984776 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 HelperResult EditField<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) | |
{ | |
var path = "/Templates/Partials/EditField/" + (template ?? "Default") + ".cshtml"; | |
var page = WebPageBase.CreateInstanceFromVirtualPath(path); | |
var context = new WebPageContext(new HttpContextWrapper(HttpContext.Current), page, null); | |
var modelMetaData = ModelMetadata.FromLambdaExpression(expression, html.ViewData); | |
var fieldname = ExpressionHelper.GetExpressionText(expression); | |
context.PageData["Validation"] = html.GetUnobtrusiveValidationAttributes(fieldname, modelMetaData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment