[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

autocomplete in derived textbox

Posted on 2011-10-07
2
Medium Priority
?
353 Views
Last Modified: 2012-08-13
If I have a custom control that derives from textbox, how would I ensure that autocomplete is turned off?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;


//Taken from
//
//http://www.codeproject.com/KB/custom-controls/ASPNET_Password_TextBox.aspx

namespace Campus_Webstore
{

    public class PasswordTextBox : TextBox
    {
        public PasswordTextBox()
        {
            TextMode = TextBoxMode.Password;
        }

        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;

                Attributes["value"] = value;
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Attributes["value"] = Text;
        }
    }
}

Open in new window

0
Comment
Question by:Tom Knowlton
2 Comments
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 2000 total points
ID: 36933976
Hello, I think that you can try this (Attributes.Add("autocomplete", "off")):
public class PasswordTextBox : TextBox
{
    public PasswordTextBox()
    {
        TextMode = TextBoxMode.Password;
        this.Attributes.Add("autocomplete", "off");
    }

    public override string Text
    {
        get
        {
            return base.Text;
        }
        set
        {
            base.Text = value;

            Attributes["value"] = value;
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        Attributes["value"] = Text;
    }
}

Open in new window

But always the client browser has the last word, so you cant guarantee that.
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 36934212
Looks right.

Thanks!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

611 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question