日期:2014-05-18  浏览次数:20566 次

当前上下文中不存在名称CreateUserWizard1,但页面中有!
register.aspx:
<%@   Page   Language= "C# "   MasterPageFile= "~/Beyond.master "   AutoEventWireup= "true "   CodeFile= "Register.aspx.cs "   Inherits= "Register "   Title= "Untitled   Page "   %>
<asp:Content   ID= "Content1 "   ContentPlaceHolderID= "ContentPlaceHolder1 "   Runat= "Server ">
    <asp:LoginView   ID= "LoginView1 "   runat= "server ">
        <LoggedInTemplate>
            You   are   already   registered.
        </LoggedInTemplate>
        <AnonymousTemplate>
            <asp:CreateUserWizard   ID= "CreateUserWizard1 "   runat= "server "   CancelDestinationPageUrl= "~/Default.aspx "
                ContinueDestinationPageUrl= "~/Default.aspx "   CreateUserButtonText= "Sign   up "   OnCreatedUser= "CreateUserWizard1_CreatedUser ">
                <WizardSteps>
                    <asp:CreateUserWizardStep   runat= "server ">
                    </asp:CreateUserWizardStep>
                    <asp:CompleteWizardStep   runat= "server ">
                    </asp:CompleteWizardStep>
                </WizardSteps>
            </asp:CreateUserWizard>
        </AnonymousTemplate>
    </asp:LoginView>
</asp:Content>

Register.aspx.cs
using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;

public   partial   class   Register   :   System.Web.UI.Page
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
            //Set   the   title   of   page
            this.Title   =   BeyondConfiguration.SiteName   +   ":   Register ";
        }
    protected   void   CreateUserWizard1_CreatedUser(object   sender,   EventArgs   e)
    {
        string   strUserName   =   CreateUserWizard1.UserName;
        string[]   arrUser   ={   strUserName   };
        Roles.AddUsersToRole(arrUser,   "Customers ");
    }
}

F5调试,出现当前上下文中不存在名称“CreateUserWizard1 ",看register.aspx的源码,可以看到CreateUserWizar