You are not Logged in
Would you like to Login or Register

Today is: Friday, 21 November, 2008
Check this months hot topics

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.

kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Paul Marshall Skype
Author : Paul Marshall
Published : Sunday, 12 August, 2007

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?????

September 12, 2007 - 1:26 PM

marshp3 said:

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

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

September 16, 2007 - 12:17 PM

SameIssue said:

In which event do you do your spiel?

September 17, 2007 - 12: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

November 16, 2007 - 1: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.

December 20, 2007 - 8: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

March 07, 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?

October 14, 2008 - 12:20 PM

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views