Default browser autocomplete does not work in my Webforms application

Asked

Viewed 350 times

4

I’m using the Google Chorme and he’s got the option autocomplete enabled, so much so that I can store a login to the Facebook.

Exemplo de autocomplete no Facebook

However, in my application ASP.NET Webforms, on the screen of login me NAY I can use that resource.
I have not applied any routine to clean up this information.

Can someone help me get the autocomplete, which is standard of browser, work in my application?

Follows my Masterpage and my page of Login:

Masterpage:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Default.Master.cs" Inherits="App.Web.PaginaMestra.Pagina" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ordem de Serviço</title>
    <script type="text/javascript" src="Js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="Js/jquery-ui-1.9.2.min.js"></script>
    <script type="text/javascript" src="Js/rots.js"></script>

    <!-[if lt IE 9]>
    <script>
        document.createElement('header');
        document.createElement('nav');
        document.createElement('section');
        document.createElement('article');
        document.createElement('aside');
        document.createElement('footer');
    </script>
    <![endif]->

    <!–[if IE]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <style type="text/css">
        body {
            background: white url(App_Themes/Default/images/bkg-blu.jpg) no-repeat center top fixed;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
        }
        .clear {
            zoom: 1;
            display: block;
        }
    </style>
    <![endif]–>
    <asp:ContentPlaceHolder ID="CPHDefaultHead" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="frmDefault" runat="server">
        <asp:ContentPlaceHolder ID="CPHDefaultBody" runat="server">
        </asp:ContentPlaceHolder>
    </form>
</body>
</html>

My page of Login:

<%@ Page Title="" Language="C#" MasterPageFile="~/PaginaMestra/Default.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="App.Web.Login" %>

<asp:Content ID="ContentLoginHead" ContentPlaceHolderID="CPHDefaultHead" runat="server">
    <script type="text/javascript">
        $(function () {
            if (window.location != parent.location) {
                parent.location = "default.aspx";
            }
        });
    </script>
</asp:Content>

<asp:Content ID="ContentLoginBody" ContentPlaceHolderID="CPHDefaultBody" runat="server">
    <asp:ScriptManager ID="scriptManagerLogin" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div style="left: 50%; margin: -150px 0 0 -200px; position: absolute; top: 50%; width: 400px">
                <asp:Panel ID="Panel1" SkinID="Panel" runat="server">
                    <asp:Panel ID="Panel2" SkinID="PanelTitle" runat="server">Login</asp:Panel>
                    <table style="width: 100%; border-spacing: 10px;">
                        <tr>
                            <td style="text-align: left; vertical-align: top;">
                                <table style="width: 100%; border-spacing: 0px;">
                                    <tr>
                                        <td style="text-align: left; vertical-align: middle;">
                                            <asp:Label runat="server" Text="Usuário" AssociatedControlID="txtUsuario"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: left; vertical-align: middle;">
                                            <asp:TextBox ID="txtUsuario" Width="200px" runat="server" autofocus="autofocus" autocomplete="on"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvUsuario" SetFocusOnError="true" runat="server" ControlToValidate="txtUsuario" ValidationGroup="Entrar"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: left; vertical-align: middle;">
                                            <asp:Label runat="server" Text="Senha" AssociatedControlID="txtSenha"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: left; vertical-align: middle;">
                                            <asp:TextBox ID="txtSenha" TextMode="Password" Width="200px" runat="server" AutoPostBack="True" OnTextChanged="txtSenha_TextChanged" ValidationGroup="Entrar"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvSenha" SetFocusOnError="true" runat="server" ControlToValidate="txtSenha" ValidationGroup="Entrar"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: left; vertical-align: middle;">
                                            <br />
                                            <asp:LinkButton ID="btnEsqueceuSenha" runat="server" OnClick="btnEsqueceuSenha_Click">Esqueceu sua senha?</asp:LinkButton>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td style="text-align: left; vertical-align: middle;">
                                <img src="App_Themes/Default/images/acesso_admin.png" style="width: 80px;" />
                            </td>
                        </tr>
                    </table>
                    <asp:Panel ID="Panel3" HorizontalAlign="Center" runat="server">
                        <asp:LinkButton ID="lkbEntrar" SkinID="Entrar" runat="server" OnClick="lkbEntrar_Click" ValidationGroup="Entrar"></asp:LinkButton>
                    </asp:Panel>
                    <br />
                </asp:Panel>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
  • If you need more information, just ask.

  • 2

    Browser autocomplete, uses attribute id or name to persist the data already informed, maybe Asp may be generating these values always different, so the browser considers this a new field, not showing the autocomplete

  • 2

    Not changing name and id.

1 answer

2


I do not see, at first, usefulness for the UpdatePanel. Test without it. It should work, and then reevaluate the use of UpdatePanel.

  • thank you, it worked! So the update panel that does it. It is probably in the post made by Submit that the browser captures this data to store. The UpdatePanel really wasn’t using it necessary. Finally, I’m ready to take over the world.

  • @José rs, is probably in POST of Submit yes.

  • @user3628 you can do it via ajax too. much simpler.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.