Visão Geral do Controle do Servidor Web TextBox

The TextBox Web server control provides a way for users to type information into an ASP.NET Web page, including text, numbers, and dates.

Esse tópico contém:

  • Segundo plano

  • Exemplos de código

  • Referência de Classe

Segundo plano

The TextBox server control is an input control that lets the user enter text.By default, the TextMode property of the control is set to TextBoxMode.SingleLine, which displays a single-line text box.However, you can set the TextMode property to TextBoxMode.MultiLine to display a multi-line text box (which renders as a textarea element).You can also change the TextMode property to TextBoxMode.Password to display a text box that masks user input.The text displayed in the TextBox control is available by using the Text property.

Observação de segurança:

configuração o TextMode propriedade para TextBoxMode.Password pode ajudar a garantir que outras pessoas não possam ver uma senha que está sendo inserido. However, the text entered into the text box is not encrypted in any way, and you should protect it as you would any other confidential data.For example, for increased security when posting a page with a password in it, you can use Secure Sockets Layer (SSL) and encryption.

Observação de segurança:

O usuário inserir em um n ASP.NET Web página pode incluir script de cliente possivelmente mal-intencionado.Por padrão, o Página da Web do ASP.NET valida que a entrada do usuário não inclui script ou elementos HTML.Para obter mais informações, consulte Visão Geral de Scripts Maliciosos.

Eventos da TextBox

The TextBox control raises a TextChanged event when the user leaves the control.By default, the event is not raised immediately; instead, it is raised on the server when the page is submitted.However, you can specify that the TextBox control should submit the page to the server as soon as the user leaves the field.

The TextBox Web server control does not raise an event each time the user enters a keystroke, only when the user leaves the control.You can have the TextBox control raise client-side events that you handle in client script, which can be useful for responding to individual keystrokes.Para obter detalhes, consulte:Script de Cliente em Páginas da Web ASP.NET.

Legendas da TextBox

You can use Label controls to create captions for TextBox controls.The caption can define an access key that users can press to navigate to the TextBox control.Para obter detalhes, consulte:Como: Use rótulo servidor Web Controls sistema autônomo legendas.

Preenchimento Automático em Caixas de Texto

Many browsers support an auto-completion feature that helps users fill information into text boxes based on values that the users have entered previously.O comportamento exato de preenchimento automático depende do navegador.In general, browsers store values based on the text box's name attribute; any text box with the same name, even on a different page, will offer the same values to the user.Alguns navegadores oferecem suporte também para um esquema vCard, o que permite aos usuários criarem um perfil em um navegador com valores predefinidos para primeiro nome, último nome, número de telefone, endereço de email, e assim por diante.

The TextBox control supports an AutoCompleteType property that provides you with these options for controlling how the browser works with auto-completion:

  • Desativar Preenchimento automático.Se você não deseja que o navegador ofereça preenchimento automático para uma caixa de texto, você pode desativá-lo.

  • Especifique um valor vCard para usar como o valor de preenchimento automático para o campo.O navegador deve oferecer suporte a esquema vCard.

Exemplos de código

Como: Obter e conjunto valores em controles do servidor Web TextBox

Como: Responder a alterações em um controle de servidor Web TextBox

Como: conjunto um controle TextBox do servidor Web para entrada de senha

Como: Especificar várias linhas de entrada para um controle TextBox do servidor Web

Voltar ao topo

Referência de Classe

A tabela seguinte lista as classes que estão relacionadas ao controle BulletedList.

Membro

Descrição

TextBox

A classe principal para o controle.

TextBoxMode

Specifies whether the TextBox control is in single-line, multi-line, or password mode.

Voltar ao topo

Consulte também

Conceitos

Visão Geral sobre Ameças de Segurança em Aplicativos da Web

Protegendo controles padrão

Referência

HtmlInputText