textbox autocomplete

Last post 02-06-2008 1:12 PM by edegagne. 12 replies.

Sort Posts:

  • textbox autocomplete

    04-13-2006, 10:48 PM
    • Member
      174 point Member
    • BarbBayne
    • Member since 11-21-2005, 11:47 PM
    • Posts 49

    I can find all kinds of posts telling how to turn autocomplete off for a textbox - but I can find nothing ( that works for me  - tried "txtUserName.Attributes.Add("autocomplete", "on");  in Page_Load among other things to get autocomplete to work for a textbox.

     

    Perhaps I have been mislead in what I have read.  So I have one question:

    If I have a form created as "Register.aspx" in VS2005 and it has an asp:Textbox control on it, is there anything I can do to see autocomplete functioning on this?  I have autocomplete turned on for forms etc and autocomplete works on other forms like google and other sites.

     

    thanks

    -Barb

  • Re: textbox autocomplete

    04-14-2006, 11:09 AM
    • All-Star
      18,370 point All-Star
    • PeterBrunone
    • Member since 06-19-2002, 9:15 AM
    • I'm standing behind you.
    • Posts 3,683
    • TrustedFriends-MVPs
       If it's not explicitly disabled at some level, autocomplete should work... unless, of course your browser doesn't support it or has it disabled (which I guess isn't the case based on your description of other sites).

        I don't suppose your site is using SSL...?


    Peter Brunone
    MS MVP, ASP.NET
    Founder, EasyListBox.com
    Do the impossible, and go home early.
  • Re: textbox autocomplete

    04-14-2006, 1:17 PM
    • Member
      174 point Member
    • BarbBayne
    • Member since 11-21-2005, 11:47 PM
    • Posts 49

    Thanks for your reply,

    No, I did not explicitly turn autocomplete off  -  it does work for other things like search boxes in other applications. Do you know of anything else I could try or experiment with to try to get this working?

    thanks

    -Barb

  • Re: textbox autocomplete

    04-14-2006, 1:48 PM
    • Member
      174 point Member
    • BarbBayne
    • Member since 11-21-2005, 11:47 PM
    • Posts 49

    Oh I forgot to mention, I am  using VS2005 on a PC with Windows XP Professional  -  I have a hosted web site that I can copy the web site to. I cannot see it working either on my computer or at the hosted site. Tried running inVS2005, copying website to local site in IIS and copying web site to my hosted site - still no luck with seeing autocomplete working

    however,  the very odd thing during my on going testing - I was seeing autocomplete for one entry one time - I cleared forms auto complete in tools | internet options | content and since have not seen anything.

     

    thanks

     

    -Barb

     

     

  • Re: textbox autocomplete

    04-14-2006, 2:03 PM
    • All-Star
      18,370 point All-Star
    • PeterBrunone
    • Member since 06-19-2002, 9:15 AM
    • I'm standing behind you.
    • Posts 3,683
    • TrustedFriends-MVPs
    Hmmm... probably a silly question, but have you submitted data since then?

    If you can upload this to a public server and post a link, maybe a look at the page would tell us more.

    Peter Brunone
    MS MVP, ASP.NET
    Founder, EasyListBox.com
    Do the impossible, and go home early.
  • Re: textbox autocomplete

    12-05-2006, 6:08 AM
    • Member
      35 point Member
    • Titi69
    • Member since 02-27-2005, 11:44 AM
    • Lyon (France)
    • Posts 7

    Hello,

     I experiment the same problem in my pages. However, I found out why it doesn't work.

    When you have an HTML button of type 'submit', then the values you entered in text boxes are correctly memorized and the next time you display this page (or another with a field with the same name), the drop down of autocomplete is available.

    However, if you submitted the page with a LinkButton for example, it calls the __doPostBack function which in turn calls the theForm.submit(). In this case, values are not memorized and the autocomplete list remains empty.

    My question is: is it a normal behavior? We have pages throughout our project with such buttons (mainly because they are highly customizable through CSS) and it sounds there is no means to benefit from the autocomplete feature.

    Any help would be greatly appreciated to make such buttons work.

    Thanks

  • Re: textbox autocomplete

    12-05-2006, 11:46 AM
    • All-Star
      18,370 point All-Star
    • PeterBrunone
    • Member since 06-19-2002, 9:15 AM
    • I'm standing behind you.
    • Posts 3,683
    • TrustedFriends-MVPs

    Dang.  That's pretty crazy, if true... but it would make a weird kind of sense.

    Can't you customize your submit button through CSS the same way?  I don't see why it would be any different, except of course for the built-in hover pseudoclass.  If you desperately need that, you could always make a simple link that calls some JS behind the scenes to click a real submit button... but then again, if you're using anything but a real submit button in your form-submitting UI, you run the risk of losing accessibility.

     

    Peter Brunone
    MS MVP, ASP.NET
    Founder, EasyListBox.com
    Do the impossible, and go home early.
  • Re: textbox autocomplete

    02-28-2007, 12:30 PM
    • Member
      2 point Member
    • mloehr
    • Member since 02-28-2007, 5:26 PM
    • Posts 1

    Peter,

    I have a situation where a client is scanning a Web server (2k3, IIS6) and it's reporting that for port 80, the AutoComplete on the username/pw fields is off, but for port 443, it's showing AutoComplete as active. We have the AutoComplete=Off tags in each field and on the form. Any ideas why the SSL port is returning different information?

    Thanks,

    Mike

  • Re: textbox autocomplete

    02-28-2007, 12:54 PM
    • All-Star
      18,370 point All-Star
    • PeterBrunone
    • Member since 06-19-2002, 9:15 AM
    • I'm standing behind you.
    • Posts 3,683
    • TrustedFriends-MVPs

    Hi Mike,

        I'm not familiar with the practice of scanning a server port to determine if AutoComplete is on or off.  What do you use for that, and what kind of output do you receive?  Are you sure it pertains to the web browser autocomplete and not some other networking attribute?


    Peter Brunone
    MS MVP, ASP.NET
    Founder, EasyListBox.com
    Do the impossible, and go home early.
  • Re: textbox autocomplete

    04-20-2007, 11:24 AM
    • Member
      35 point Member
    • edegagne
    • Member since 12-01-2003, 8:01 AM
    • Ashby, MA
    • Posts 10

    I am having similar issues in IE only with my server controls.

    Here's what makes implementing field by field autocomplete more frustrating;

    The System.Web.UI.TextBox control supports a property called AutoCompleteType. It's an enumeration of many possible values, even a AutoCompleteType.Disabled.

    In IE, this is implemented by adding an attribute of autocomplete="off" on your behalf. If you select another value (like AutoCompleteType.FirstName), then an attribute is created for you like this: vcard_name="vCard.FirstName". Even then, autocomplete is still not working in IE (still trying to track down why).

    In FireFox (and other browsers not IE), the AutoCompleteType property is completely avoided, so if you set it to AutoCompleteType.Disabled, the autocomplete="off" is NOT added for you.

    It's a very poor implementation and one that doesn't lend itself very nicely for cross browser support. 

    200 x 85
    Keep your stick on the ice
  • Re: hello world

    04-20-2007, 2:46 PM
    • Member
      35 point Member
    • edegagne
    • Member since 12-01-2003, 8:01 AM
    • Ashby, MA
    • Posts 10

    The culprit is that unless an actual form submit is fired, then IE will not save your autocomplete values. In my case, I am using linkbuttons and they do not fire a form submit.

    A fix is to override the __doPostback javascript function to get autosave values to save.

    Ex:

    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
        theform = document.forms["Form1"];
    }
    else {
        theform = document.Form1;
    }

    // Override the base __doPostBack function
    var orig_doPostBack = __doPostBack;

    function pd_PostBack(Param1, Param2)
    {
        // If IE, we need to explicitly run AutoComplete
        // so form values are remembered.
        if (document.all)
        {
            window.external.AutoCompleteSaveForm(theform);
        }  
         
        // Set back to original __doPostBack.
        __doPostBack = orig_doPostBack;
        __doPostBack(Param1, Param2);
    }
    __doPostBack = pd_PostBack;


    I also had another jscript function that needed to be overidden as well:

    // Override the base WebForm_DoPostBackWithOptions function.
    var orig_WebForm_DoPostBackWithOptions = WebForm_DoPostBackWithOptions;

    function pd_DoPostBackWithOptions(options)
    {
        // If IE, we need to explicitly run AutoComplete
        // so form values are remembered.
        if (document.all)
        {
            window.external.AutoCompleteSaveForm(theform);
        }  

        // Set back to original WebForm_DoPostBackWithOptions.
        WebForm_DoPostBackWithOptions = orig_WebForm_DoPostBackWithOptions;
        WebForm_DoPostBackWithOptions(options);
    }
    WebForm_DoPostBackWithOptions = pd_DoPostBackWithOptions;

     

    This solver the issue for me and was based (and tweaked for my instance) from a MSDN article highlighting the fact that the autosave values are only saved on a submit form.

    Folks, this is an IE only issue.
     

    200 x 85
    Keep your stick on the ice
  • Re: hello world

    02-06-2008, 10:23 AM

    Thank you very much..worked great for me.

    In my case I am submitting the form in javascript function and intially autocomplete didn't work.

    So I have just included this statement window.external.AutoCompleteSaveForm(theform); in the javascript function before the submit function is called and the autocomplete worked fine.

  • Re: hello world

    02-06-2008, 1:12 PM
    • Member
      35 point Member
    • edegagne
    • Member since 12-01-2003, 8:01 AM
    • Ashby, MA
    • Posts 10

    Glad it helped you!

     Cool
     

    200 x 85
    Keep your stick on the ice
Page 1 of 1 (13 items)