0

源错误:

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

我有一个 createuserwizard。如果用户在步骤 2 中输入错误,则该事件将被取消。我使用 e.cancel = true 来做到这一点。但它导致了这个错误。

'CreateUserWizard1_CreatedUser' 没有重载匹配委托 '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"
>
4

2 回答 2

0

您需要使用 OnCreatingUser 事件。

    <asp:CreateUserWizard ID="CreateUserWizard1"   //here is line 62 
        runat="server" 
        OnCreatingUser="CreateUserWizard1_CreatedUser"
...

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard.oncreatinguser

于 2012-07-23T14:40:24.440 回答
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
}
于 2012-07-23T14:44:48.273 回答