Resetting ChangePassword control
If you try using the ChangePassword control for changing several passwords on the same page, you will notice that after confirming successful password change the control always shows the same success message and doesn't offer any text entry fields any more. The reason is that the control maintains an internal state machine and doesn't reset it properly after succes password changes. The state machine is controlled by internal property CurrentView that is not available for direct setting. But you can set it using reflection like this:
private void resetChangePasswordState(System.Web.UI.WebControls.ChangePassword cpControl)
{
System
.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic |System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static;
System
.Type type = cpControl.GetType();System.Reflection.PropertyInfo p = type.GetProperty("CurrentView", flags);
System
.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(p.PropertyType);object result = converter.ConvertFrom("ChangePassword"); p.SetValue(cpControl, result, null);
}