Clearing all textboxes on CreateUserWizard control in ASP.NET 2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asumal
    New Member
    • Apr 2008
    • 2

    Clearing all textboxes on CreateUserWizard control in ASP.NET 2.0

    Hello

    I am new to ASP.NET. I am using CreateUserWizar d control to register & create a user. I am using Membership API. I have a Cancel button on the CreateUserWizar d step 2 alongwith Create User button & Previous button. Actually, i have added some more textboxes on the default control for taking user's personal information. The problem is that when i call the below mentioned code all textboxes for user's personal information gets cleared but not the default controls on the CreateUserWizar d control which takes user's login ,Security question & answer information. My code is as follows:

    protected void CreateUserWizar d2_CancelButton Click(object sender, EventArgs e)
    {//Calling a function & passing all the createuserwizar d controls
    DisplayControl( CreateUserWizar d2.CreateUserSt ep.ContentTempl ateContainer.Co ntrols);
    fstname.Focus() ;
    }

    private void DisplayControl( ControlCollecti on Controls)
    { //recusive routine that can go through the entire control hierarchy
    //making empty all textbox controls except with id=username
    foreach (System.Web.UI. Control control in Controls)
    {
    if (control is System.Web.UI.W ebControls.Text Box )
    {
    if (((System.Web.U I.WebControls.T extBox)control) .ID != "UserName")
    ((System.Web.UI .WebControls.Te xtBox)control). Text = "";
    }
    if (control.Contro ls != null)
    {
    DisplayControl( control.Control s);
    }
    }

    }
Working...