PasswordRecovery是asp.net控件

时间:2009-04-09 15:02:18

标签: asp.net user-controls asp.net-2.0

我正在尝试访问提交按钮,该按钮是asp.net 2.0中PasswordRecovery控件的一部分。据我所知,API不允许这样做。

有任何想法如何在单击此按钮时添加Javascript确认弹出窗口。

我试图在SendingMail事件中添加onclick到PasswordRecovery控件的属性,如下所示,但没有运气。

 protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
    {
        //storing audit information
        PasswordRecovery myPasswordRecovery = new PasswordRecovery();
        myPasswordRecovery = (PasswordRecovery)sender;
        myPasswordRecovery.SubmitButton.Attributes.Add("onclick", "return confirm('" + confirmationMessage + "');");

}

2 个答案:

答案 0 :(得分:2)

我会尝试模板控件并替换提交按钮。

<asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" ValidationGroup="PasswordRecovery1" OnClientClick="return confirm('You sure you want to recover?');" />

How to: Customize the Password Recovery Control

答案 1 :(得分:0)

您是否在尝试访问按钮时指定模板,例如:

passwordRecovery.UserNameTemplateContainer.FindControl("submitButton")