Show CreateUserWizard error message label

I have a CreateUserWizard control and am doing server side validation. Is there a way to get the CUW error message to display from code? Currently, if the user enters a duplicate name, the DuplicateUserNameErrorMessage property is displayed. However, if the user turned off javascript or sent a custom POST header with invalid characters, I rely on my server side check to catch the error. How can I then display the same error message in the ErrorMessage control label instead of creating a custom label and fake?

Edit: just to clarify, server-side validation checks various aspects. The repeating user was just an example of when the ErrorMessage label is invoked by a control.

thanks

+4
source share
1 answer

Update:

Here is something that will work, but requires private thought:

void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e) { typeof(CreateUserWizard).GetField( "_unknownErrorMessage", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) .SetValue(sender, "My error message"); e.Cancel = true; } 

Basically, you will set the error message you want for this field, and CreateUserWizard will select it. As a private reflection, this is not a โ€œsupportedโ€ technique, but at least it is an option to consider if nothing works.


I donโ€™t think you need to do anything special for this. Typically, anything that supports client-side validation has server-side validation logic. Actually, for something like a duplicate name, there is only server side validation, so I don't think disabling javascript should affect the script.

What exactly do you see when you turn off javascript and you post a duplicate name? If you can reproduce this problem with a simple page, or are there some additional factors that may affect it?

I tried using simple CUW and turned off javascript and a repeating user error was played.

+4
source

All Articles