Export (0) Print
Expand All
Expand Minimize

CreateUserWizard.Answer Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the end user's answer to the password recovery confirmation question.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[ThemeableAttribute(false)] 
[LocalizableAttribute(true)] 
public virtual string Answer { get; set; }
/** @property */
public String get_Answer ()

/** @property */
public void set_Answer (String value)

public function get Answer () : String

public function set Answer (value : String)

Property Value

The end user's answer to the password recovery confirmation question. The default value is an empty string ("").

The membership provider specified in the MembershipProvider property will determine whether the question and answer text boxes are displayed at run time.

If an answer is required by the membership provider specified in the MembershipProvider property, then the answer text box will appear on the CreateUserWizard control. Each text box displayed on the CreateUserWizard control has a RequiredFieldValidator object associated with it.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins Overview.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

The following code example modifies the e-mail message in the SendingMail event to include the user's password recovery confirmation answer in the message that is sent to new users.

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);
    }
  }
}

The following code example demonstrates a Web page that uses the CustomCreateUserWizard.

<%@ Page Language="C#"%>
<%@ Import namespace="Samples.AspNet.CS.Controls" %>

<script runat="server">
private void Page_Load(object sender, EventArgs e) {    
    Placeholder1.Controls.Add(new CustomCreateUserWizard());
}
</script>

<html>
<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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft