如何在MVC HTML辅助禁用自动完成 [英] How to disable autocomplete in MVC Html Helper

查看:212
本文介绍了如何在MVC HTML辅助禁用自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个典型的ADO.NET EF驱动形式,它允许用户输入的日期。我已经把一个jQuery的日期选择器上,但是当用户进入到选择一个日期,浏览器显示一个下拉其他一些条目。我如何关闭该下拉列表?在传统的ASP.NET我会把自动完成=关闭。不知道MVC当量。

 < D​​IV CLASS =主编场>
    <%= Html.TextBoxFor(型号=> model.date,新{@class =aDatePicker})%GT;
    <%= Html.ValidationMessageFor(型号=> model.date)%GT;
< / DIV>


解决方案

试试这个:

 <%= Html.TextBoxFor(
    模型=> model.date,
    新{@class =aDatePicker,自动完成=关闭}
)%GT;

这将生成标记是接近以下内容:

 <输入类型=文本ID =日期NAME =日期级=aDatePicker自动完成=关闭/>

I have a typical ADO.NET EF-driven form that allows the user to input a date. I have put a jQuery datepicker on it but when the user goes to select a date the browser shows some other entries in a dropdown. How do I turn off that dropdown? In traditional ASP.NET I would put autocomplete="off". Not sure of the MVC equivalent.

<div class="editor-field">
    <%= Html.TextBoxFor(model => model.date, new { @class = "aDatePicker" })%>
    <%= Html.ValidationMessageFor(model => model.date) %>
</div> 

解决方案

Try this:

<%= Html.TextBoxFor(
    model => model.date, 
    new { @class = "aDatePicker", autocomplete = "off" }
)%>

It will generate markup that is close to the following:

<input type="text" id="date" name="date" class="aDatePicker" autocomplete="off" />

这篇关于如何在MVC HTML辅助禁用自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆