MembershipUser.Email 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定成員資格使用者的電子郵件地址。
public:
virtual property System::String ^ Email { System::String ^ get(); void set(System::String ^ value); };
public virtual string Email { get; set; }
member this.Email : string with get, set
Public Overridable Property Email As String
屬性值
成員資格用戶的電子郵件位址。
範例
下列程式代碼範例會顯示 中的所有 ListBox 成員資格用戶名稱,並使用標籤顯示所選取使用者名稱的特定成員資格資訊,包括 Email 成員資格使用者的屬性。
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
MembershipUserCollection users;
public void Page_Load()
{
users = Membership.GetAllUsers();
if (!IsPostBack)
{
// Bind users to ListBox.
UsersListBox.DataSource = users;
UsersListBox.DataBind();
}
// If a user is selected, show the properties for the selected user.
if (UsersListBox.SelectedItem != null)
{
MembershipUser u = users[UsersListBox.SelectedItem.Value];
EmailLabel.Text = u.Email;
IsOnlineLabel.Text = u.IsOnline.ToString();
LastLoginDateLabel.Text = u.LastLoginDate.ToString();
CreationDateLabel.Text = u.CreationDate.ToString();
LastActivityDateLabel.Text = u.LastActivityDate.ToString();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: View User Information</title>
</head>
<body>
<form runat="server" id="PageForm">
<h3>View User Information</h3>
<table border="0" cellspacing="4">
<tr>
<td valign="top">
<asp:ListBox id="UsersListBox" DataTextField="Username"
Rows="8" AutoPostBack="true" runat="server" />
</td>
<td valign="top">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td>Email:</td>
<td><asp:Label runat="server" id="EmailLabel" /></td>
</tr>
<tr>
<td>Is Online?:</td>
<td><asp:Label runat="server" id="IsOnlineLabel" /></td>
</tr>
<tr>
<td>LastLoginDate:</td>
<td><asp:Label runat="server" id="LastLoginDateLabel" /></td>
</tr>
<tr>
<td>CreationDate:</td>
<td><asp:Label runat="server" id="CreationDateLabel" /></td>
</tr>
<tr>
<td>LastActivityDate:</td>
<td><asp:Label runat="server" id="LastActivityDateLabel" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim users As MembershipUserCollection
Public Sub Page_Load()
users = Membership.GetAllUsers()
If Not IsPostBack Then
' Bind users to ListBox.
UsersListBox.DataSource = users
UsersListBox.DataBind()
End If
' If a user is selected, show the properties for the selected user.
If Not UsersListBox.SelectedItem Is Nothing Then
Dim u As MembershipUser = users(UsersListBox.SelectedItem.Value)
EmailLabel.Text = u.Email
IsOnlineLabel.Text = u.IsOnline.ToString()
LastLoginDateLabel.Text = u.LastLoginDate.ToString()
CreationDateLabel.Text = u.CreationDate.ToString()
LastActivityDateLabel.Text = u.LastActivityDate.ToString()
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: View User Information</title>
</head>
<body>
<form runat="server" id="PageForm">
<h3>View User Information</h3>
<table border="0" cellspacing="4">
<tr>
<td valign="top">
<asp:ListBox id="UsersListBox" DataTextField="Username"
Rows="8" AutoPostBack="true" runat="server" />
</td>
<td valign="top">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td>Email:</td>
<td><asp:Label runat="server" id="EmailLabel" /></td>
</tr>
<tr>
<td>Is Online?:</td>
<td><asp:Label runat="server" id="IsOnlineLabel" /></td>
</tr>
<tr>
<td>LastLoginDate:</td>
<td><asp:Label runat="server" id="LastLoginDateLabel" /></td>
</tr>
<tr>
<td>CreationDate:</td>
<td><asp:Label runat="server" id="CreationDateLabel" /></td>
</tr>
<tr>
<td>LastActivityDate:</td>
<td><asp:Label runat="server" id="LastActivityDateLabel" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>