禁止在MVC HTML辅助文本自动完成 [英] Disable autocomplete on html helper textbox in MVC

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

问题描述

好吧,

我会在正常使用asp.net一个主题来关闭自动完成对所有文本框在整个网站。不过,我不能做到这一点MVC的,因为没有什么主题。皮肤文件似乎工作。

I would in normal asp.net use a theme to turn off autocomplete on all text boxes on an entire site. However i cannot do this on MVC because nothing in the theme .skin files seems to work.

我有这个在我的。皮肤文件:

I have this in my .skin file:

<asp:TextBox runat="server" autocomplete="off" />

然而,这并未使所有课程,因为这不是MVC是如何工作的。反正有没有什么办法可以让这样的事情工作。
我试图做到这一点的网站是太大,没有必要更改每个文本框或创建一个新的HTML帮助解决这个问题?

however this does not render at all, of course because this is not how MVC works. Anyway is there any way i can get this sort of thing to work. The site i am trying to do it on is too big to warrant changing every textbox or creating a new HTML helper to solve the issue?

任何人有什么想法?

推荐答案

有关问题的答案的家伙,但是这些解决方案将真正需要我来编辑所有形式的网站,如果你看到了我们正在做使用MVC的欢呼声中,你会理解的。

Cheers for the answers guys, however those solutions would really require me to edit all the forms in the site, if you saw the use of MVC we are doing, you would understand.

无论如何,我选择了这种方式,在母版页添加此脚本:

Anyway i opted for this way, in the master page i added this script:

<script language="javascript" type="text/javascript">
        $(document).ready(function () {
            try {
                $("input[type='text']").each(function(){
                               $(this).attr("autocomplete","off");
                            });
            }
            catch (e)
            { }
        });

    </script>

我知道,如果禁用JavaScript这不过是毫无价值的,如果禁用JavaScript的用户将无法使用一半的部位是诚实的。

I know if javascript is disabled this is worthless however to be honest if javascript is disabled the users won't be able to use half the site.

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

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