PasswordRecovery.QuestionTemplate 屬性

定義

取得或設定用於顯示 PasswordRecovery 控制項之 [問題] 檢視的樣板。

public:
 virtual property System::Web::UI::ITemplate ^ QuestionTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.PasswordRecovery))]
public virtual System.Web.UI.ITemplate QuestionTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.PasswordRecovery))>]
member this.QuestionTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property QuestionTemplate As ITemplate

屬性值

ITemplate

ITemplate,包含用於在 [問題] 檢視中顯示 PasswordRecovery 控制項的樣板。 預設為 null

屬性

範例

下列程式碼範例顯示 [問題] 檢視的預設範本。

重要

此範例包含一個文字方塊,可接受使用者輸入,這是潛在的安全性威脅。 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。

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

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

備註

屬性 QuestionTemplate 包含範本,定義 [問題] 檢視中控制項的外觀 PasswordRecovery

下表列出問題檢視範本中使用的必要和選擇性控制項。

識別碼或命令名稱 控制項類型 必要條件/選擇性
Answer 任何實作 的 IEditableTextControl 控制項。 必要
Submit 造成事件反升的任何控制項。 選擇性

[提交] 控制項可以是造成事件反升的任何控制項,例如 ButtonLinkButtonImageButton 。 控制項的命令名稱屬性必須設定為 「Submit」。

如果 [問題] 檢視不包含必要的控制項,控制項 PasswordRecovery 就會 HttpException 擲回例外狀況。 如果您為錯誤類型的控制項提供選擇性控制項識別碼,則不會擲回例外狀況;不過,控制項後續會 PasswordRecovery 忽略控制項。

當您使用範本來定義 [問題] 檢視的外觀時,只有下列屬性會影響控制項的行為:

當您使用 [問題] 檢視的範本時,所有其他屬性都會處於非作用中狀態。

適用於

另請參閱