CreateUserWizard Error Messages using a ContentTempate

In our latest project we are implementing Membership, Roles and Profiles. I've used these before, but never really had the need to exploit all the features.

The business requirements of the system have meant that I have had to implement a custom CreateUserWizard ContentTemplate, which is great feature of the control. I can set all of the error message properties, but I just couldn't work out how to get my custom error text onto the screen. I even tried putting code into the OnCreateUserError event to trap an error and display the error text, and this doesn't work because the error text in the event isn't what you specified in the control.

After trawling the web, I found the solution.

<asp:Literal runat="server" EnableViewState="false" ID="ErrorMessage"></asp:Literal>

The Control must look for this literal when it is in error, and populates it.

How easy was that?!

I'd normally close by suggesting a beer, but its too early on a sunday..

Hope this helps someone.

Author Paul Marshall

A self confessed Microsoft bigot, Paul loves all Microsoft products with a particular fondness for SQL Server. Paul is currently focusing on Web 2.0 patterns and practices and is always looking for better ways of doing things.

I love the .net platform, and I find it to be the most productive toolset I have used to date.

Comments

Joe-M said:

So, did this ever actually work???

I can see the Literal tag in the aspx code but if you try to find it to set in the code-behind (C# in my case), "ErrorMessage" is nowhere to be found.

How'd ya do it?????

12/Sep/2007 13:26 PM

marshp3 said:

Joe, you need to do a FindControl on the ContentTemplateContainer of the WizardStep.

Literal errorLiteral = (Literal)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ErrorMessage");

16/Sep/2007 12:17 PM

SameIssue said:

In which event do you do your spiel?

17/Sep/2007 00:38 AM

root_hacker said:

i am also using this Literal and it works great but i want to catch the event if error occurred. for my case CreateUserWizard1 not firing up when username already exist in database

16/Nov/2007 13:26 PM

jaywon said:

Protected Sub CreateUserWizard1_CreateUserError(ByVal sender As Object, ByVal e As CreateUserErrorEventArgs) Handles OwnerAddWizard1.CreateUserError

End Sub

This will catch the error event.

20/Dec/2007 20:26 PM

ephrem said:

Thanks for your sharing us

But I got one issue.

I handle the event OnCreateUserError and set the ErrorMessage litral control to customized error message but this litral control always display the built-in error message b ignoring the one I set

How do I overide the builtin error message by customized one?

Thanks,

Ephrem

07/Mar/2008 12:34 PM

Jeppe said:

I can find this control and i can set my error message to what i like, but it wont show?? How do i make this literal showing?

14/Oct/2008 12:20 PM

Add Comment

Name
Comment
 

Your comment has been received and will be shown once it passes moderation.