2012-07-23 84 views
0

源錯誤:沒有重載 'CreateUserWizard1_CreatedUser' 匹配委託 'System.EventHandler'

Line 62:   <asp:CreateUserWizard ID="CreateUserWizard1" // error appeared here 
Line 63:    runat="server" 
Line 64:    OnCreatedUser="CreateUserWizard1_CreatedUser" 

我有一個CreateUserWizard控件。如果用戶在步驟2中輸入錯誤,則該事件將被取消。我用e.cancel = true來做到這一點。但它導致了這個錯誤。

No overload for 'CreateUserWizard1_CreatedUser' matches delegate 'System.EventHandler'

後面的代碼:

protected void CreateUserWizard1_CreatedUser(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e) 
{  
    MSCaptcha.CaptchaControl Captcha1 = (CreateUserWizardStep1.ContentTemplateContainer.FindControl("Captcha1") as MSCaptcha.CaptchaControl); 

    TextBox txtCaptcha = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txtCaptcha"); 
    Label Captchalbl = (Label)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Captchalbl"); 

    Response.Write(txtCaptcha.Text); 

    Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim()); 

    if (!Captcha1.UserValidated) 
    {    
     Captchalbl.Text = "InValid"; 
     Response.Write(Captchalbl.Text); 
     // Captchalbl.ForeColor = System.Drawing.Color.Red; 
     e.Cancel = true; 
    } 
    else 
    { 
     Captchalbl.Text = "Valid"; 
     Response.Write(Captchalbl.Text); 
     TextBox UserNameTextBox = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"); 
     SqlDataSource dataSource = (SqlDataSource)CreateUserWizardStep1.ContentTemplateContainer.FindControl("InsertExtraInfo"); 
     MembershipUser user = Membership.GetUser(UserNameTextBox.Text); 
     dataSource.InsertParameters.Add("UserId", user.ProviderUserKey.ToString()); 
     dataSource.Insert();     
    } 
} 

下面是代碼:

<asp:CreateUserWizard ID="CreateUserWizard1" //here is line 62 
     runat="server" 
     OnCreatedUser="CreateUserWizard1_CreatedUser" 
     InvalidPasswordErrorMessage="Password length must be more than 8 characters." 
     ContinueDestinationPageUrl="~/Home.aspx" 
     DisplayCancelButton = "True" 
     CancelDestinationPageUrl="~/Home.aspx" 
     DisableCreatedUser="True" 
     OnSendingMail="CreateUserWizard1_SendingMail" 
> 

回答

0

標記:

OnCreatingUser="CreateUserWizard1_CreatingUser" 
OnCreatedUser="CreateUserWizard1_CreatedUser" 

代碼隱藏:

protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) 
{ 
    // Occurs before the membership provider is called to create the new Web site user account 
} 

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) 
{ 
    // Occurs after the membership provider has created the new Web site user account 
} 
相關問題