GeekZilla
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.
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?????
marshp3 said:
Joe, you need to do a FindControl on the ContentTemplateContainer of the WizardStep.
Literal errorLiteral = (Literal)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ErrorMessage");
SameIssue said:
In which event do you do your spiel?
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
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.
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
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?