Login.UserName 속성

정의

사용자가 입력한 사용자 이름을 가져옵니다.

public:
 virtual property System::String ^ UserName { System::String ^ get(); void set(System::String ^ value); };
public virtual string UserName { get; set; }
member this.UserName : string with get, set
Public Overridable Property UserName As String

속성 값

사용자가 입력한 사용자 이름입니다. 기본값은 Empty입니다.

예제

다음 코드 예제에서는 UserName 사용자 지정 인증 방법에 속성을 전달 합니다.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
{
    // Insert code that implements a site-specific custom 
    // authentication method here.
    //
    // This example implementation always returns false.
    return false;
}

private void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    bool Authenticated = false;
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);

    e.Authenticated = Authenticated;
}

</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"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>
        </form>
    </body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Function SiteSpecificAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
    ' Insert code that implements a site-specific custom 
    ' authentication method here.
    '
    ' This example implementation always returns false.
    Return False
End Function

Sub OnAuthenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
    Dim Authenticated As Boolean
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)

    e.Authenticated = Authenticated
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"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>

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

설명

속성에는 UserName 사용자가 입력한 사용자 이름이 포함됩니다. Login 같은 입력란에서 표시 하는 속성을 제어할 UserNamePassword, 페이지 수명 주기의 모든 단계 동안 액세스할 수 있습니다. 컨트롤을 이용 하 여 최종 사용자가 변경한 모든 내용을 선택 된 TextChanged 된 텍스트 상자에 의해 트리거되는 이벤트입니다.

적용 대상

추가 정보