This documentation is archived and is not being maintained.

PasswordRecovery.QuestionTemplate Property

Gets or sets the template used to display the Question view of the PasswordRecovery control.

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

[TemplateContainerAttribute(typeof(PasswordRecovery))] 
public virtual ITemplate QuestionTemplate { get; set; }
/** @property */
public ITemplate get_QuestionTemplate ()

/** @property */
public void set_QuestionTemplate (ITemplate value)

public function get QuestionTemplate () : ITemplate

public function set QuestionTemplate (value : ITemplate)

Not applicable.

Property Value

An ITemplate that contains the template for displaying the PasswordRecovery control in Question view. The default is a null reference (Nothing in Visual Basic).

The QuestionTemplate property contains the template that defines the appearance of the PasswordRecovery control in Question view.

The following table lists the required and optional controls used in the Question view template.

ID or Command name

Control type

Required/optional

Answer

Any control that implements IEditableTextControl.

Required

Submit

Any control that causes event bubbling.

Optional

The Submit control can be any control that causes event bubbling, such as Button, LinkButton, or ImageButton. The control's command name property must be set to "Submit".

The PasswordRecovery control throws an HttpException exception if the Question view does not contain the required controls. No exception is thrown if you give an optional control ID to a control of the wrong type; however, the control is subsequently ignored by the PasswordRecovery control.

When you use a template to define the appearance of the Question view, only the following properties affect the behavior of the control:

All other properties are inactive when you use a template for the Question view.

The following code example shows the default template for the Question view.

Security noteSecurity Note:

This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio).

<%@ 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">

</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:passwordrecovery id="PasswordRecovery1" runat="server">
        <questiontemplate>
            <table border="0">
                <tr>
                    <td align="Center" colspan="2">Identity Confirmation</td>
                </tr>
                <tr>
                    <td align="Center" colspan="2">Answer the following question to receive your password.</td>
                </tr>
                <tr>
                    <td align="Right">User Name:</td>
                    <td>
                        <asp:literal runat="server" id="UserName"></asp:literal>
                    </td>
                </tr>
                <tr>
                    <td align="Right">Question:</td>
                    <td>
                        <asp:literal runat="server" id="Question"></asp:literal>
                    </td>
                </tr>
                <tr>
                    <td align="Right">Answer:</td>
                    <td>
                        <asp:textbox runat="server" id="Answer"></asp:textbox>
                        <asp:requiredfieldvalidator runat="server" controltovalidate="Answer" errormessage="Answer." id="AnswerRequired">*</asp:requiredfieldvalidator>
                    </td>
                </tr>
                <tr>
                    <td align="Right" colspan="2">
                        <asp:button runat="server" commandname="Submit" text="Submit" id="Button"></asp:button>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="color:Red;">
                        <asp:literal runat="server" id="FailureText"></asp:literal>
                    </td>
                </tr>
            </table>
        </questiontemplate>
    </asp:passwordrecovery>

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

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: