通过


Login 类

定义

提供用于登录到网站的用户界面(UI)元素。

public ref class Login : System::Web::UI::WebControls::CompositeControl
[System.ComponentModel.Bindable(false)]
public class Login : System.Web.UI.WebControls.CompositeControl
[<System.ComponentModel.Bindable(false)>]
type Login = class
    inherit CompositeControl
Public Class Login
Inherits CompositeControl
继承
属性

示例

下面的代码示例使用控件 Login 提供用于登录网站的 UI。

<%@ Page Language="C#" %>
<%@ Import Namespace="System.ComponentModel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
bool IsValidEmail(string strIn)
{
    // Return true if strIn is in valid email format.
    return Regex.IsMatch(strIn, @"^([\w\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); 
}

void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
{
    if (!IsValidEmail(Login1.UserName))
    {
        Login1.InstructionText = "Enter a valid email address.";
        Login1.InstructionTextStyle.ForeColor = System.Drawing.Color.RosyBrown;
        e.Cancel = true;
    }
    else
    {
        Login1.InstructionText = String.Empty;
    }
}

void OnLoginError(object sender, EventArgs e)
{
    Login1.HelpPageText = "Help with logging in...";
    Login1.PasswordRecoveryText = "Forgot your password?";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" 
                BorderStyle="Solid" 
                BackColor="#F7F7DE" 
                BorderWidth="1px"
                BorderColor="#CCCC99" 
                Font-Size="10pt" 
                Font-Names="Verdana" 
                CreateUserText="Create a new user..."
                CreateUserUrl="newUser.aspx" 
                HelpPageUrl="help.aspx"
                PasswordRecoveryUrl="getPass.aspx" 
                UserNameLabelText="Email address:" 
                OnLoggingIn="OnLoggingIn"
                OnLoginError="OnLoginError" >
                <TitleTextStyle Font-Bold="True" 
                    ForeColor="#FFFFFF" 
                    BackColor="#6B696B">
                </TitleTextStyle>
            </asp:Login>

        </form>
    </body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.ComponentModel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Function IsValidEmail(ByVal strIn As String) As Boolean
    ' Return true if strIn is in valid email format.
    Return Regex.IsMatch(strIn, ("^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"))
End Function

Sub OnLoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs)
    If Not IsValidEmail(Login1.UserName) Then
        Login1.InstructionText = "Enter a valid email address."
        Login1.InstructionTextStyle.ForeColor = System.Drawing.Color.RosyBrown
        e.Cancel = True
    Else
        Login1.InstructionText = String.Empty
    End If
End Sub

Sub OnLoginError(ByVal sender As Object, ByVal e As EventArgs)
    Login1.HelpPageText = "Help with logging in..."
    Login1.PasswordRecoveryText = "Forgot your password?"
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" 
                BorderStyle="Solid" 
                BackColor="#F7F7DE" 
                BorderWidth="1px"
                BorderColor="#CCCC99" 
                Font-Size="10pt" 
                Font-Names="Verdana" 
                CreateUserText="Create a new user..."
                CreateUserUrl="newUser.aspx" 
                HelpPageUrl="help.aspx"
                PasswordRecoveryUrl="getPass.aspx" 
                UserNameLabelText="Email address:" 
                OnLoggingIn="OnLoggingIn"
                OnLoginError="OnLoginError" >
                <TitleTextStyle Font-Bold="True" 
                    ForeColor="#FFFFFF" 
                    BackColor="#6B696B">
                </TitleTextStyle>
            </asp:Login>

        </form>
    </body>
</html>

下面的代码示例演示如何扩展 Login 控件。 该 CustomLogin 控件包含一个 DropDownList 控件,允许用户选择其进行身份验证的成员资格提供程序。 (这些提供程序是在 Web.config中配置的。在方法中 OnLoggingIn ,属性 MembershipProvider 设置为控件的 DropDownList 选定值。

重要

此示例包含接受用户输入的文本框,这是潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅 脚本攻击概述

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Samples.AspNet.Controls
{
    public sealed class CustomLogin : Login
    {
        public CustomLogin() { }
        
        protected override void OnLoggingIn(LoginCancelEventArgs e)
        {
            // Set the Membership provider for the Login control from a DropDownList.
            DropDownList list = (DropDownList)this.FindControl("domain");
            this.MembershipProvider = list.SelectedValue;
            base.OnLoggingIn(e);
        }
        
        protected override void CreateChildControls()
        {
            LayoutTemplate = new MyTemplate();
            base.CreateChildControls();
        }
    }
    
    // A Template that contains the child controls.
    public class MyTemplate : ITemplate
    {
        void ITemplate.InstantiateIn(Control container)
        {
            // A TextBox for the user name.
            TextBox username = new TextBox();
            username.ID = "username";
            
            // A TextBox for the password.
            TextBox password = new TextBox();
            password.ID = "password";
            
            // A CheckBox to remember the user on subsequent visits.
            CheckBox remember = new CheckBox();
            remember.ID = "RememberMe";
            remember.Text = "Don't forget me!";
            
            // Failure Text.
            Literal failure = new Literal();
            failure.ID = "FailureText";
            
            // A DropDownList to choose the Membership provider.
            DropDownList domain = new DropDownList();
            domain.ID = "Domain";
            domain.Items.Add(new ListItem("SqlMembers"));
            domain.Items.Add(new ListItem("SqlMembers2"));
            
            // A Button to log in.
            Button submit = new Button();
            submit.CommandName = "login";
            submit.Text = "LOGIN";

            container.Controls.Add(new LiteralControl("UserName:"));
            container.Controls.Add(username);
            container.Controls.Add(new LiteralControl("<br>Password:"));
            container.Controls.Add(password);
            container.Controls.Add(new LiteralControl("<br>"));
            container.Controls.Add(remember);
            container.Controls.Add(new LiteralControl("<br>Domain:"));
            container.Controls.Add(domain);
            container.Controls.Add(new LiteralControl("<br>"));
            container.Controls.Add(failure);
            container.Controls.Add(new LiteralControl("<br>"));
            container.Controls.Add(submit);
        }
    }    
}
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Namespace Samples.AspNet.Controls

    NotInheritable Public Class CustomLogin
        Inherits Login

        Public Sub New() 
        End Sub

        Protected Overrides Sub OnLoggingIn(ByVal e As LoginCancelEventArgs) 

            ' Set the Membership provider for the Login control from a DropDownList.
            Dim list As DropDownList = CType(Me.FindControl("domain"), DropDownList)
            Me.MembershipProvider = list.SelectedValue
            MyBase.OnLoggingIn(e)

        End Sub


        Protected Overrides Sub CreateChildControls() 

            LayoutTemplate = New MyTemplate()
            MyBase.CreateChildControls()

        End Sub
    End Class

    ' A Template that contains the child controls.
    Public Class MyTemplate
        Implements ITemplate

        Sub InstantiateIn(ByVal container As Control)  Implements ITemplate.InstantiateIn
            ' A TextBox for the user name.
            Dim username As New TextBox()
            username.ID = "username"

            ' A TextBox for the password.
            Dim password As New TextBox()
            password.ID = "password"

            ' A CheckBox to remember the user on subsequent visits.
            Dim remember As New CheckBox()
            remember.ID = "RememberMe"
            remember.Text = "Don't forget me!"

            ' Failure Text.
            Dim failure As New Literal()
            failure.ID = "FailureText"

            ' A DropDownList to choose the Membership provider.
            Dim domain As New DropDownList()
            domain.ID = "Domain"
            domain.Items.Add(New ListItem("SqlMembers"))
            domain.Items.Add(New ListItem("SqlMembers2"))

            ' A Button to log in.
            Dim submit As New Button()
            submit.CommandName = "login"
            submit.Text = "LOGIN"

            container.Controls.Add(New LiteralControl("UserName:"))
            container.Controls.Add(username)
            container.Controls.Add(New LiteralControl("<br>Password:"))
            container.Controls.Add(password)
            container.Controls.Add(New LiteralControl("<br>"))
            container.Controls.Add(remember)
            container.Controls.Add(New LiteralControl("<br>Domain:"))
            container.Controls.Add(domain)
            container.Controls.Add(New LiteralControl("<br>"))
            container.Controls.Add(failure)
            container.Controls.Add(New LiteralControl("<br>"))
            container.Controls.Add(submit)

        End Sub
    End Class
End Namespace

注解

在本主题中:

介绍

Login 控件是一个复合控件,它提供对网站上的用户进行身份验证所需的所有常见 UI 元素。 所有登录方案都需要以下三个元素:

  • 用于标识用户的唯一用户名。

  • 用于验证用户标识的密码。

  • 用于将登录信息发送到服务器的登录按钮。

Login 控件还提供支持其他函数的以下可选 UI 元素:

  • 密码提醒的链接。

  • 用于在会话之间保留登录信息的“记住我”复选框。

  • 登录时遇到问题的用户的帮助链接。

  • 将用户重定向到注册页的“注册新用户”链接。

  • 登录窗体上显示的说明文本。

  • 当用户单击登录按钮时出现的自定义错误文本,无需填写用户名或密码字段。

  • 登录失败时出现的自定义错误文本。

  • 登录成功时发生的自定义操作。

  • 如果用户已登录到站点,则隐藏登录控件的方法。

有关显示所需控件和可选控件的表,请参阅 LayoutTemplate 属性。

注释

如果不熟悉 ASP.NET 中可用的登录控件集,请参阅 ASP.NET 登录控件概述 ,然后再继续操作。 有关与登录控件和成员身份相关的其他主题的列表,请参阅 使用成员身份管理用户

重要

接受用户输入是潜在的安全威胁。 恶意用户可以发送旨在公开漏洞或运行尝试生成的密码的程序的数据。 若要在处理用户输入时提高安全性,应使用控件的验证功能,并保护为控件配置的任何数据提供程序。 有关详细信息,请参阅 保护登录控件Web 应用程序的基本安全做法以及 保护成员身份

Login 控件使用成员资格提供程序来获取用户凭据。 除非另有指定,否则该 Login 控件将使用在 Web.config 文件中定义的默认成员身份提供程序。 若要指定其他提供程序,请将 MembershipProvider 属性设置为应用程序 Web.config 文件中定义的成员资格提供程序名称之一。 有关详细信息,请参阅 成员资格提供程序

如果要使用自定义身份验证服务,可以使用 OnAuthenticate 该方法调用该服务。

样式和模板

控件的外观 Login 可通过模板和样式设置完全自定义。 所有 UI 文本消息也可以通过类的属性 Login 进行自定义。 默认接口文本根据服务器上的区域设置自动本地化。

如果控件是使用模板自定义的 Login ,则 AccessKey 忽略该属性和 TabIndex 属性。 在这种情况下,请 AccessKey 直接设置每个模板子控件的属性和 TabIndex 属性。

Login 在页面生命周期的所有阶段都可以访问由文本框(如 UserNamePassword)表示的控件属性。 控件将通过文本框触发的事件选取最终用户 TextChanged 所做的任何更改。

注释

如果在对象中嵌入控件Login,则如果用户经过身份验证,则显式设置ActiveStepIndex事件处理程序中的Page_LoadWizardStep属性。 此 Wizard 控件不会自动前进到此方案中的下一个 WizardStep 对象。

下表列出了 Login 控件样式属性,并说明了每个样式属性影响哪些 UI 元素。 有关每个样式适用的属性的列表,请参阅各个样式属性的文档。

Style 属性 受影响的 UI 元素
BorderPadding 控件内容与控件边框之间的空间。
CheckBoxStyle 记住我复选框。
FailureTextStyle 登录失败文本。
InstructionTextStyle 页面上指示用户如何使用控件的说明性文本。
LabelStyle 所有输入字段(如文本框)的标签。
TextBoxStyle 文本输入输入字段。
TitleTextStyle 标题文本。
ValidatorTextStyle 由于验证错误,登录尝试失败时向用户显示的文本。
HyperLinkStyle 指向其他页面的链接。
LoginButtonStyle 登录按钮。

验证分组

属性UserNamePassword具有RequiredFieldValidator与其关联的控件,以防止用户提交页面,而无需提供所需的信息。

Login 控件使用验证组,以便可以单独验证控件 Login 所在的同一页上的其他字段。 默认情况下, ID 控件的属性 Login 用作验证组的名称。 例如, Login ID 为“Login1”的控件将使用验证组名称“Login1”。 如果要设置控件所属的 Login 验证组,则必须对控件进行模板化并更改验证组名称。

应用 CSS 样式

Login 控件允许你在标记中指定 CSS 样式规则。 如果使用模板自定义控件的外观 Login ,则可以在模板中的标记中指定 CSS 样式。 在这种情况下,不需要额外的外部表。 通过将属性设置为 RenderOuterTablefalse.,可以阻止呈现表。

可及性

有关如何配置此控件以便生成符合辅助功能标准的标记的信息,请参阅 Visual Studio 中的辅助功能以及 ASP.NETASP.NET 控件和辅助功能

声明性语法

<asp:Login
    AccessKey="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderPadding="integer"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
    BorderWidth="size"
    CreateUserIconUrl="uri"
    CreateUserText="string"
    CreateUserUrl="uri"
    CssClass="string"
    DestinationPageUrl="uri"
    DisplayRememberMe="True|False"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    FailureAction="Refresh|RedirectToLoginPage"
    FailureText="string"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
               Large|X-Large|XX-Large"
    Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    HelpPageIconUrl="uri"
    HelpPageText="string"
    HelpPageUrl="uri"
    ID="string"
    InstructionText="string"
    LoginButtonImageUrl="uri"
    LoginButtonText="string"
    LoginButtonType="Button|Image|Link"
    MembershipProvider="string"
    OnAuthenticate="Authenticate event handler"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnLoggedIn="LoggedIn event handler"
    OnLoggingIn="LoggingIn event handler"
    OnLoginError="LoginError event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    Orientation="Horizontal|Vertical"
    PasswordLabelText="string"
    PasswordRecoveryIconUrl="uri"
    PasswordRecoveryText="string"
    PasswordRecoveryUrl="uri"
    PasswordRequiredErrorMessage="string"
    RememberMeSet="True|False"
    RememberMeText="string"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    TextLayout="TextOnLeft|TextOnTop"
    TitleText="string"
    ToolTip="string"
    UserName="string"
    UserNameLabelText="string"
    UserNameRequiredErrorMessage="string"
    Visible="True|False"
    VisibleWhenLoggedIn="True|False"
    Width="size"
>
        <CheckBoxStyle />
        <FailureTextStyle />
        <HyperLinkStyle />
        <InstructionTextStyle />
        <LabelStyle />
        <LayoutTemplate>
            <!-- child controls -->
        </LayoutTemplate>
        <LoginButtonStyle />
        <TextBoxStyle />
        <TitleTextStyle />
        <ValidatorTextStyle />
</asp:Login>

构造函数

名称 说明
Login()

创建控件的新实例 Login

字段

名称 说明
LoginButtonCommandName

表示与登录按钮关联的命令名称。

属性

名称 说明
AccessKey

获取或设置访问密钥,使你能够快速导航到 Web 服务器控件。

(继承自 WebControl)
Adapter

获取控件的特定于浏览器的适配器。

(继承自 Control)
AppRelativeTemplateSourceDirectory

获取或设置包含此控件的 PageUserControl 对象的应用程序相对虚拟目录。

(继承自 Control)
Attributes

获取不对应于控件上的属性的任意属性(仅用于呈现)的集合。

(继承自 WebControl)
BackColor

获取或设置 Web 服务器控件的背景色。

(继承自 WebControl)
BindingContainer

获取包含此控件的数据绑定的控件。

(继承自 Control)
BorderColor

获取或设置 Web 控件的边框颜色。

(继承自 WebControl)
BorderPadding

获取或设置控件边框 Login 内的填充量。

BorderStyle

获取或设置 Web 服务器控件的边框样式。

(继承自 WebControl)
BorderWidth

获取或设置 Web 服务器控件的边框宽度。

(继承自 WebControl)
CheckBoxStyle

获取对定义 Style “记住我”复选框设置的对象的引用。

ChildControlsCreated

获取一个值,该值指示是否已创建服务器控件的子控件。

(继承自 Control)
ClientID

获取由 ASP.NET 生成的 HTML 标记的控件 ID。

(继承自 Control)
ClientIDMode

获取或设置用于生成属性值的 ClientID 算法。

(继承自 Control)
ClientIDSeparator

获取一个表示属性中使用的 ClientID 分隔符的字符值。

(继承自 Control)
Context

HttpContext获取与当前 Web 请求的服务器控件关联的对象。

(继承自 Control)
Controls

获取一个 ControlCollection 对象,该对象表示 .. 中的 CompositeControl子控件。

(继承自 CompositeControl)
ControlStyle

获取 Web 服务器控件的样式。 此属性主要由控件开发人员使用。

(继承自 WebControl)
ControlStyleCreated

获取一个值,该值 Style 指示是否已为 ControlStyle 属性创建对象。 此属性主要由控件开发人员使用。

(继承自 WebControl)
CreateUserIconUrl

获取要显示在新用户的注册页链接旁的图像的位置。

CreateUserText

获取或设置新用户的注册页的链接文本。

CreateUserUrl

获取或设置新用户注册页的 URL。

CssClass

获取或设置由客户端上的 Web 服务器控件呈现的级联样式表 (CSS) 类。

(继承自 WebControl)
DataItemContainer

获取对命名容器的引用(如果命名容器实现 IDataItemContainer)。

(继承自 Control)
DataKeysContainer

获取对命名容器的引用(如果命名容器实现 IDataKeysControl)。

(继承自 Control)
DesignMode

获取一个值,该值指示控件是否在设计图面上使用。

(继承自 Control)
DestinationPageUrl

获取或设置登录尝试成功时向用户显示的页面的 URL。

DisplayRememberMe

获取或设置一个值,该值指示是否显示复选框,使用户能够控制是否将持久 Cookie 发送到其浏览器。

Enabled

获取或设置一个值,该值指示是否启用 Web 服务器控件。

(继承自 WebControl)
EnableTheming

获取或设置一个值,该值指示主题是否应用于此控件。

(继承自 WebControl)
EnableViewState

获取或设置一个值,该值指示服务器控件是否将视图状态及其包含的任何子控件的视图状态保存到请求客户端。

(继承自 Control)
Events

获取控件的事件处理程序委托的列表。 此属性为只读。

(继承自 Control)
FailureAction

获取或设置登录尝试失败时发生的操作。

FailureText

获取或设置登录尝试失败时显示的文本。

FailureTextStyle

获取对定义控件中错误文本外观的属性集合的 Login 引用。

Font

获取与 Web 服务器控件关联的字体属性。

(继承自 WebControl)
ForeColor

获取或设置 Web 服务器控件的前景色(通常是文本的颜色)。

(继承自 WebControl)
HasAttributes

获取一个值,该值指示控件是否设置了属性。

(继承自 WebControl)
HasChildViewState

获取一个值,该值指示当前服务器控件的子控件是否具有保存的视图状态设置。

(继承自 Control)
Height

获取或设置 Web 服务器控件的高度。

(继承自 WebControl)
HelpPageIconUrl

获取要显示在登录帮助页链接旁边的图像的位置。

HelpPageText

获取或设置指向登录帮助页的链接的文本。

HelpPageUrl

获取或设置登录帮助页的 URL。

HyperLinkStyle

获取对定义控件中 Login 超链接外观的属性集合的引用。

ID

获取或设置分配给服务器控件的编程标识符。

(继承自 Control)
IdSeparator

获取用于分隔控件标识符的字符。

(继承自 Control)
InstructionText

获取或设置用户的登录说明文本。

InstructionTextStyle

获取对定义 TableItemStyle 控件中指令文本设置的对象的 Login 引用。

IsChildControlStateCleared

获取一个值,该值指示此控件中包含的控件是否具有控件状态。

(继承自 Control)
IsEnabled

获取一个值,该值指示是否启用控件。

(继承自 WebControl)
IsTrackingViewState

获取一个值,该值指示服务器控件是否正在保存对其视图状态的更改。

(继承自 Control)
IsViewStateEnabled

获取一个值,该值指示是否为此控件启用视图状态。

(继承自 Control)
LabelStyle

获取对 TableItemStyle 定义控件标签设置的对象的 Login 引用。

LayoutTemplate

获取或设置用于显示控件的 Login 模板。

LoadViewStateByID

获取一个值,该值指示控件是否参与加载其视图状态,而不是 ID 索引。

(继承自 Control)
LoginButtonImageUrl

获取或设置要用于登录按钮的图像的 URL。

LoginButtonStyle

获取对 Style 对象的引用,该对象允许设置控件中 Login 登录按钮的外观。

LoginButtonText

获取或设置控件的登录按钮的文本 Login

LoginButtonType

获取或设置在 Login 呈现按钮时要使用的按钮类型。

MembershipProvider

获取或设置控件使用的成员身份数据提供程序的名称。

NamingContainer

获取对服务器控件命名容器的引用,该容器创建唯一的命名空间,用于区分具有相同 ID 属性值的服务器控件。

(继承自 Control)
Orientation

获取或设置一个值,该值指定控件在页面上的 Login 元素的位置。

Page

获取对 Page 包含服务器控件的实例的引用。

(继承自 Control)
Parent

获取对页面控件层次结构中服务器控件的父控件的引用。

(继承自 Control)
Password

获取用户输入的密码。

PasswordLabelText

获取或设置文本框的标签 Password 文本。

PasswordRecoveryIconUrl

获取图像的位置,该图像显示在指向密码恢复页面的链接旁边。

PasswordRecoveryText

获取或设置指向密码恢复页的链接的文本。

PasswordRecoveryUrl

获取或设置密码恢复页的 URL。

PasswordRequiredErrorMessage

获取或设置在密码字段留空时在控件中显示的 ValidationSummary 错误消息。

RememberMeSet

获取或设置一个值,该值指示是否将持久身份验证 Cookie 发送到用户的浏览器。

RememberMeText

获取或设置“记住我”复选框的标签文本。

RenderingCompatibility

获取一个值,该值指定呈现的 HTML 将与 ASP.NET 版本兼容。

(继承自 Control)
RenderOuterTable

获取或设置一个值,该值指示控件是否将呈现的 HTML 括在元素中 table 以应用内联样式。

Site

获取有关在设计图面上呈现时承载当前控件的容器的信息。

(继承自 Control)
SkinID

获取或设置要应用于控件的皮肤。

(继承自 WebControl)
Style

获取文本属性的集合,该属性将在 Web 服务器控件的外部标记上呈现为样式属性。

(继承自 WebControl)
SupportsDisabledAttribute

获取一个值,该值指示当控件的属性为控件的属性时,控件是否应将呈现的 IsEnabled HTML 元素的属性false设置为disabled“disabled”。

(继承自 CompositeControl)
TabIndex

获取或设置 Web 服务器控件的选项卡索引。

(继承自 WebControl)
TagKey

HtmlTextWriterTag获取与Login控件对应的值。 此属性主要由控件开发人员使用。

TagName

获取控件标记的名称。 此属性主要由控件开发人员使用。

(继承自 WebControl)
TemplateControl

获取或设置对包含此控件的模板的引用。

(继承自 Control)
TemplateSourceDirectory

获取包含当前服务器控件的 Page 虚拟 UserControl 目录。

(继承自 Control)
TextBoxStyle

获取对定义控件中文本框外观的属性集合的 Login 引用。

TextLayout

指定每个标签相对于控件的关联文本框 Login 的位置。

TitleText

获取或设置控件的 Login 标题。

TitleTextStyle

获取对属性集合的引用,这些属性定义控件中 Login 标题文本的外观。

ToolTip

获取或设置鼠标指针悬停在 Web 服务器控件上时显示的文本。

(继承自 WebControl)
UniqueID

获取服务器控件的唯一分层限定标识符。

(继承自 Control)
UserName

获取用户输入的用户名。

UserNameLabelText

获取或设置文本框的标签 UserName 文本。

UserNameRequiredErrorMessage

获取或设置在用户名字段留空时在控件中显示的 ValidationSummary 错误消息。

ValidateRequestMode

获取或设置一个值,该值指示控件是否检查浏览器的客户端输入是否存在潜在危险值。

(继承自 Control)
ValidatorTextStyle

获取对属性集合的 Style 引用,这些属性定义与控件使用的 Login 验证程序关联的错误消息的外观。

ViewState

获取状态信息的字典,该字典允许跨同一页的多个请求保存和还原服务器控件的视图状态。

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示对象是否 StateBag 不区分大小写。

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。

(继承自 Control)
Visible

获取或设置一个值,该值指示服务器控件是否呈现为页面上的 UI。

(继承自 Control)
VisibleWhenLoggedIn

获取或设置一个值,该值指示在对用户进行身份验证后是否显示 Login 控件。

Width

获取或设置 Web 服务器控件的宽度。

(继承自 WebControl)

方法

名称 说明
AddAttributesToRender(HtmlTextWriter)

将需要呈现的 HTML 属性和样式添加到指定的 HtmlTextWriterTag。 此方法主要由控件开发人员使用。

(继承自 WebControl)
AddedControl(Control, Int32)

在将子控件添加到 Controls 对象的集合 Control 后调用。

(继承自 Control)
AddParsedSubObject(Object)

通知服务器控件对元素(XML 或 HTML)进行了分析,并将该元素添加到服务器控件的对象 ControlCollection

(继承自 Control)
ApplyStyle(Style)

将指定样式的任何非空白元素复制到 Web 控件,覆盖该控件的任何现有样式元素。 此方法主要由控件开发人员使用。

(继承自 WebControl)
ApplyStyleSheetSkin(Page)

将页面样式表中定义的样式属性应用于控件。

(继承自 Control)
BeginRenderTracing(TextWriter, Object)

开始对呈现数据进行设计时跟踪。

(继承自 Control)
BuildProfileTree(String, Boolean)

收集有关服务器控件的信息,并将其传送到 Trace 为页面启用跟踪时要显示的属性。

(继承自 Control)
ClearCachedClientID()

将缓存 ClientID 的值设置为 null

(继承自 Control)
ClearChildControlState()

删除服务器控件的子控件的控件状态信息。

(继承自 Control)
ClearChildState()

删除所有服务器控件的子控件的视图状态和控件状态信息。

(继承自 Control)
ClearChildViewState()

删除所有服务器控件的子控件的视图状态信息。

(继承自 Control)
ClearEffectiveClientIDMode()

ClientIDMode 当前控件实例的属性和任何子控件的属性设置为 Inherit

(继承自 Control)
CopyBaseAttributes(WebControl)

将对象未封装 Style 的属性从指定的 Web 服务器控件复制到从中调用此方法的 Web 服务器控件。 此方法主要由控件开发人员使用。

(继承自 WebControl)
CreateChildControls()

创建构成控件的各个控件 Login ,并将事件处理程序与其事件相关联。

CreateControlCollection()

创建一个新 ControlCollection 对象,用于保存服务器控件的子控件(文本控件和服务器)。

(继承自 Control)
CreateControlStyle()

创建类在内部用于实现所有样式相关属性的 WebControl 样式对象。 此方法主要由控件开发人员使用。

(继承自 WebControl)
DataBind()

将数据源绑定到 CompositeControl 其所有子控件。

(继承自 CompositeControl)
DataBind(Boolean)

将数据源绑定到已调用的服务器控件及其所有子控件,并提供引发 DataBinding 事件的选项。

(继承自 Control)
DataBindChildren()

将数据源绑定到服务器控件的子控件。

(继承自 Control)
Dispose()

使服务器控件能够在从内存释放之前执行最终清理。

(继承自 Control)
EndRenderTracing(TextWriter, Object)

结束呈现数据的设计时跟踪。

(继承自 Control)
EnsureChildControls()

确定服务器控件是否包含子控件。 如果没有,它将创建子控件。

(继承自 Control)
EnsureID()

为未分配标识符的控件创建标识符。

(继承自 Control)
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
FindControl(String, Int32)

在当前命名容器中搜索具有指定 id 和整数的服务器控件(在参数中指定的 pathOffset 整数),这有助于搜索。 不应重写此方法的 FindControl 此版本。

(继承自 Control)
FindControl(String)

使用指定 id 参数搜索服务器控件的当前命名容器。

(继承自 Control)
Focus()

将输入焦点设置为控件。

(继承自 Control)
GetDesignModeState()

获取控件的设计时数据。

(继承自 Control)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetRouteUrl(Object)

获取对应于一组路由参数的 URL。

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

获取对应于一组路由参数的 URL。

(继承自 Control)
GetRouteUrl(String, Object)

获取对应于一组路由参数和路由名称的 URL。

(继承自 Control)
GetRouteUrl(String, RouteValueDictionary)

获取对应于一组路由参数和路由名称的 URL。

(继承自 Control)
GetType()

获取当前实例的 Type

(继承自 Object)
GetUniqueIDRelativeTo(Control)

返回指定控件属性的前缀部分 UniqueID

(继承自 Control)
HasControls()

确定服务器控件是否包含任何子控件。

(继承自 Control)
HasEvents()

返回一个值,该值指示是为控件或任何子控件注册事件。

(继承自 Control)
IsLiteralContent()

确定服务器控件是否仅保留文本内容。

(继承自 Control)
LoadControlState(Object)

从方法保存 SaveControlState() 的上一页请求中还原控件状态信息。

(继承自 Control)
LoadViewState(Object)

从使用该方法保存 SaveViewState() 的上一个请求还原视图状态信息。

MapPathSecure(String)

检索虚拟路径映射到的物理路径(绝对路径或相对路径)。

(继承自 Control)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
MergeStyle(Style)

将指定样式的任何非空白元素复制到 Web 控件,但不会覆盖该控件的任何现有样式元素。 此方法主要由控件开发人员使用。

(继承自 WebControl)
OnAuthenticate(AuthenticateEventArgs)

Authenticate引发事件以对用户进行身份验证。

OnBubbleEvent(Object, EventArgs)

确定是否将事件向上传递页面的用户界面(UI)服务器控件层次结构。

OnDataBinding(EventArgs)

引发 DataBinding 事件。

(继承自 Control)
OnInit(EventArgs)

引发 Init 事件。

(继承自 Control)
OnLoad(EventArgs)

引发 Load 事件。

(继承自 Control)
OnLoggedIn(EventArgs)

LoggedIn在用户登录到网站并经过身份验证后引发该事件。

OnLoggingIn(LoginCancelEventArgs)

LoggingIn当用户提交登录信息但在身份验证发生之前引发事件。

OnLoginError(EventArgs)

LoginError当登录尝试失败时引发事件。

OnPreRender(EventArgs)

实现基 OnPreRender(EventArgs) 方法。

OnUnload(EventArgs)

引发 Unload 事件。

(继承自 Control)
OpenFile(String)

获取用于读取文件的一个 Stream

(继承自 Control)
RaiseBubbleEvent(Object, EventArgs)

将事件的任何源及其信息分配给控件的父级。

(继承自 Control)
RecreateChildControls()

在派生自 CompositeControl的控件中重新创建子控件。

(继承自 CompositeControl)
RemovedControl(Control)

Controls 对象的集合 Control 中删除子控件后调用。

(继承自 Control)
Render(HtmlTextWriter)

使用指定的 HTML 编写器呈现登录表单。

RenderBeginTag(HtmlTextWriter)

将控件的 HTML 开始标记呈现给指定的编写器。 此方法主要由控件开发人员使用。

(继承自 WebControl)
RenderChildren(HtmlTextWriter)

将服务器控件的子级的内容输出到所提供的 HtmlTextWriter 对象,该对象写入要呈现在客户端上的内容。

(继承自 Control)
RenderContents(HtmlTextWriter)

将控件的内容呈现给指定的编写器。 此方法主要由控件开发人员使用。

(继承自 WebControl)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的对象将服务器控件内容输出到所提供的HtmlTextWriterControlAdapter对象。

(继承自 Control)
RenderControl(HtmlTextWriter)

将服务器控件内容输出到提供 HtmlTextWriter 的对象,并在启用跟踪时存储有关控件的跟踪信息。

(继承自 Control)
RenderEndTag(HtmlTextWriter)

将控件的 HTML 结束标记呈现到指定的编写器中。 此方法主要由控件开发人员使用。

(继承自 WebControl)
ResolveAdapter()

获取负责呈现指定控件的控件适配器。

(继承自 Control)
ResolveClientUrl(String)

获取浏览器可以使用的 URL。

(继承自 Control)
ResolveUrl(String)

将 URL 转换为在请求客户端上可用 URL。

(继承自 Control)
SaveControlState()

保存自页面发回服务器后发生的任何服务器控件状态更改。

(继承自 Control)
SaveViewState()

保存调用方法后 TrackViewState() 修改的任何状态。

SetDesignModeState(IDictionary)

设置控件的设计时数据。

SetRenderMethodDelegate(RenderMethod)

分配事件处理程序委托以将服务器控件及其内容呈现为其父控件。

(继承自 Control)
SetTraceData(Object, Object, Object)

使用跟踪对象、跟踪数据键和跟踪数据值为呈现数据的设计时跟踪设置跟踪数据。

(继承自 Control)
SetTraceData(Object, Object)

使用跟踪数据键和跟踪数据值为呈现数据的设计时跟踪设置跟踪数据。

(继承自 Control)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
TrackViewState()

重写基 TrackViewState() 方法。

活动

名称 说明
Authenticate

在对用户进行身份验证时发生。

DataBinding

当服务器控件绑定到数据源时发生。

(继承自 Control)
Disposed

在从内存中释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生命周期的最后阶段。

(继承自 Control)
Init

在初始化服务器控件时发生,这是其生命周期中的第一步。

(继承自 Control)
Load

在将服务器控件加载到对象中 Page 时发生。

(继承自 Control)
LoggedIn

当用户登录到网站并经过身份验证时发生。

LoggingIn

在用户提交登录信息之前,在进行身份验证之前发生。

LoginError

检测到登录错误时发生。

PreRender

Control 加载对象但在呈现之前发生。

(继承自 Control)
Unload

从内存中卸载服务器控件时发生。

(继承自 Control)

显式接口实现

名称 说明
IAttributeAccessor.GetAttribute(String)

获取具有指定名称的 Web 控件的属性。

(继承自 WebControl)
IAttributeAccessor.SetAttribute(String, String)

将 Web 控件的属性设置为指定的名称和值。

(继承自 WebControl)
ICompositeControlDesignerAccessor.RecreateChildControls()

使设计器能够在设计时环境中重新创建复合控件的子控件集合。

(继承自 CompositeControl)
IControlBuilderAccessor.ControlBuilder

有关此成员的说明,请参阅 ControlBuilder

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

有关此成员的说明,请参阅 GetDesignModeState()

(继承自 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

有关此成员的说明,请参阅 SetDesignModeState(IDictionary)

(继承自 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

有关此成员的说明,请参阅 SetOwnerControl(Control)

(继承自 Control)
IControlDesignerAccessor.UserData

有关此成员的说明,请参阅 UserData

(继承自 Control)
IDataBindingsAccessor.DataBindings

有关此成员的说明,请参阅 DataBindings

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

有关此成员的说明,请参阅 HasDataBindings

(继承自 Control)
IExpressionsAccessor.Expressions

有关此成员的说明,请参阅 Expressions

(继承自 Control)
IExpressionsAccessor.HasExpressions

有关此成员的说明,请参阅 HasExpressions

(继承自 Control)
IParserAccessor.AddParsedSubObject(Object)

有关此成员的说明,请参阅 AddParsedSubObject(Object)

(继承自 Control)

扩展方法

名称 说明
EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>)

为指定的数据控件启用动态数据行为。

EnableDynamicData(INamingContainer, Type, Object)

为指定的数据控件启用动态数据行为。

EnableDynamicData(INamingContainer, Type)

为指定的数据控件启用动态数据行为。

FindDataSourceControl(Control)

返回与指定控件的数据控件关联的数据源。

FindFieldTemplate(Control, String)

返回指定控件命名容器中指定列的字段模板。

FindMetaTable(Control)

返回包含数据控件的元表对象。

GetDefaultValues(INamingContainer)

获取指定数据控件的默认值的集合。

GetMetaTable(INamingContainer)

获取指定数据控件的表元数据。

SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>)

设置指定数据控件的表元数据和默认值映射。

SetMetaTable(INamingContainer, MetaTable, Object)

设置指定数据控件的表元数据和默认值映射。

SetMetaTable(INamingContainer, MetaTable)

设置指定数据控件的表元数据。

TryGetMetaTable(INamingContainer, MetaTable)

确定表元数据是否可用。

适用于

另请参阅