views:

545

answers:

2

I'm trying to access the submit button which is part of the PasswordRecovery control within asp.net 2.0. The API as far as I can see does not allow this.

Has anyone any ideas how I can add a Javascript confirmation popup window when clicking this button.

I have tried to add onclick to the attributes of the PasswordRecovery control within the SendingMail event as below but no luck.

 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 + "');");

}

A: 

Are you specifying the template when attempting to access the button, e.g:

passwordRecovery.UserNameTemplateContainer.FindControl("submitButton")
dommer
A: 

I would attempt to template the control and replace the submit button.

<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

scottschulthess