CreateUserWizard.Answer 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定使用者對密碼復原確認問題的解答。
public:
virtual property System::String ^ Answer { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.Themeable(false)]
public virtual string Answer { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.Answer : string with get, set
Public Overridable Property Answer As String
屬性值
使用者對密碼復原確認問題的解答。 預設值為空字串 ("")。
- 屬性
範例
下列程式代碼範例會修改 事件中的 SendingMail 電子郵件訊息,以在傳送給新使用者的訊息中包含使用者的密碼復原確認答案。
using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls {
[AspNetHostingPermission (System.Security.Permissions.SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (System.Security.Permissions.SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class CustomCreateUserWizard : CreateUserWizard
{
public CustomCreateUserWizard()
{
this.MailDefinition.BodyFileName = "MailFile.txt";
this.MailDefinition.From = "userAdmin@your.site.name.here";
}
protected override void OnSendingMail(MailMessageEventArgs e)
{
e.Message.Subject = "New Web site user.";
// Replace placeholder text in message body with information
// provided by the user.
e.Message.Body.Replace("<%PasswordQuestion%>",this.Question);
e.Message.Body.Replace("<%PasswordAnswer%>", this.Answer);
base.OnSendingMail(e);
}
}
}
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(System.Security.Permissions.SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class CustomCreateUserWizard
Inherits CreateUserWizard
Public Sub New()
Me.MailDefinition.BodyFileName = "MailFile.txt"
Me.MailDefinition.From = "userAdmin@your.site.name.here"
End Sub
Protected Overloads Sub OnSendingMail(ByVal e As MailMessageEventArgs)
e.Message.Subject = "New user on Web site."
' Replace placeholder text in message body with information
' provided by the user.
e.Message.Body.Replace("<%PasswordQuestion%>", Me.Question)
e.Message.Body.Replace("<%PasswordAnswer%>", Me.Answer)
MyBase.OnSendingMail(e)
End Sub
End Class
End Namespace
下列程式代碼範例示範使用 的 CustomCreateUserWizard
網頁。
<%@ Page Language="C#"%>
<%@ Import namespace="Samples.AspNet.CS.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
private void Page_Load(object sender, EventArgs e) {
Placeholder1.Controls.Add(new CustomCreateUserWizard());
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>CreateUserWizard.OnSendingMail sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:placeholder id="Placeholder1" runat="server" >
</asp:placeholder>
</div>
</form>
</body>
</html>
<%@ Page Language="VB"%>
<%@ Import namespace="Samples.AspNet.VB.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim createUser As New CustomCreateUserWizard
Placeholder1.Controls.Add(createUser)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>CreateUserWizard.OnSendingMail sample</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:placeholder id="Placeholder1" runat="server" >
</asp:placeholder>
</div>
</form>
</body>
</html>
備註
屬性中指定的 MembershipProvider 成員資格提供者會判斷問題與答案文本框是否在運行時間顯示。
如果屬性中指定的 MembershipProvider 成員資格提供者需要答案,則回應文本框會出現在 CreateUserWizard 控件上。 控件上 CreateUserWizard 顯示的每個文本框都有 RequiredFieldValidator 與其相關聯的物件。
這個屬性無法由佈景主題或樣式表主題設定。 如需詳細資訊,請參閱 ThemeableAttribute 和 ASP.NET 主題和面板。
當設定時,此屬性的值可以使用設計工具自動儲存到資源檔。 如需詳細資訊,請參閱 LocalizableAttribute和全球化和當地語系化。