<%= Html.EditorFor(product => product.Name) %>
autocomplete = "off"속성을 설정하려면 생성 된 출력이 필요합니다.EditorFor를 사용하여 입력란의 자동 완성을 사용 중지하는 방법은 무엇입니까?
내가 무엇이 누락 되었습니까?
편집 : 나는 속성에 대한 키/값 사전을 받아 EditorFor에 대한 확장 방법을 찾고 있어요, 그래서 다음과 같이 호출 할 수 있습니다 <%= Html.EditorFor(product => product.Name, new { autocomplete = "off" }) %>
다음
그것은 동시에, labelFor 수행됩니다 있지만에 필요 Edit2가
public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object htmlAttributes) {
return LabelFor(html, expression, new RouteValueDictionary(htmlAttributes));
}
public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes)
{
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
string labelText = metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last();
if (String.IsNullOrEmpty(labelText))
{
return MvcHtmlString.Empty;
}
TagBuilder tag = new TagBuilder("label");
tag.MergeAttributes(htmlAttributes);
tag.Attributes.Add("for", html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName));
tag.SetInnerText(labelText);
return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
}
EditorFor
조절할 수 : 이미 익명의 유형을 받아들이는 오버라이드 (override) EditorFor이 존재하기 때문에이 여기 http://msdn.microsoft.com/en-us/library/ff406462.aspx를 참조 EditorFor을 지정할 수 없습니다 실현 .. 어쨌든, 우리는 아니, 다르게 이름을 지정할 수 있습니다 거물.
현재 값을 가져야합니다. . – randomguy