我在文本框中添加了一个提示模板。该模板在firefox和chrome上运行良好,但它没有出现在IE10上。
模型属性:
[Display(Name = "Age*" , Prompt="Enter Number: ")]
public string Age { get; set; }视图:
@Html.EditorFor(c => c.Age, new { @class = "form_txt" }) 模板:
Views\Shared\EditorTemplates\String.chtml:
@Html.TextBox(string.Empty, ViewData.TemplateInfo.FormattedModelValue, new
{
@class = "form_item txt txt_gray box_gray_focus rounded_corner",
placeholder = ViewData.ModelMetadata.Watermark,
title = ViewData.ModelMetadata.Description
})发布于 2013-08-25 14:52:48
Html.EditorFor没有以htmlAttributes对象作为参数的实现。您正在使用该方法的以下实现,这意味着您将class = "form_txt"作为ViewData传递给您的EditorTemplate。
public static MvcHtmlString EditorFor<TModel, TValue>(
this HtmlHelper<TModel> html,
Expression<Func<TModel, TValue>> expression,
Object additionalViewData
)您需要做的是在class中定义EditorTemplate属性,并像这样使用Html.EditorFor:
@Html.EditorFor(c => c.Age)发布于 2013-08-25 14:06:36
如果你不使用EditorTemplate,只使用视图中的TextBoxFor .它在IE10中工作吗?
@Html.TextBoxFor(x => x.Age, new
{
@class = "form_txt",
placeholder = "Here enter your Age",
title = "This is the title"
})IE直到IE9没有实现占位符,但它是看来IE10应该支持它。由于占位符不是标签的替代品,它只是一个提示,无论如何,您不应该依赖它们。
据说,有一些jquery插件可以在不支持浏览器或版本的情况下处理这个问题。
https://stackoverflow.com/questions/18429490
复制相似问题