ASP.NET Registration with multiple profile providers

When do you decide it is time to give up on using some of the more feature rich ASP.NET controls? When is it easier and/or quicker to code something yourself?

I spent yesterday trying to plug the CreateUserWizard into an e-commerce website. It was very simple to get working and very little code was required. However once I got it working, I then had the interesting task of getting it to produce the required HTML. I edited the templates; getting rid of the entire messy table based HTML, and thought everything was going good. It wasn’t.

When I loaded the registration page up in Firefox, and viewed source, I could see the nice template HTML was surrounded by more hideous HTML that the CreateUserWizard had generated. The hideous HTML was not part of a template so could no be changed.

After googling around I found a very exciting discovery – the ASP.NET CSS Friendly Control Adapters. A set of adapters that can be dropped into an application and will help adapt´┐Ż the HTML that the ASP.NET controls render, making them CSS friendly.

I wired up the adapters and loaded up my site in Firefox, and then viewed source. Woo hoo, the HTML was fixed, with not a table to be seen.

But then another pothole….

I tried to create a user and hit all sorts of problems. After a bit of debugging, I found out that when the adapters are plugged in, the CreateUserWizard doesn’t quite work the same. My event handlers were not working because the properties such as UserName on the CreateUserWizard were empty! I ended up having to use FindControl to get the values that I needed instead of accessing the properties. I have since found Steven Harman’s excellent blog post – CSS Friendly Control Adapters, CreateUserWizard, and ViewState… Oh My! – that covers this in more detail.

Okay, so I tweaked my code and everything seems to be working again, but from reading more about Steven’s experiences it seems like there may still be some outstanding issues with the CreateUserWizard and the CSS Friendly Control Adapters.
Which brings me to the question at the beginning of the post – When do you decide it is time to give up on using some of the more feature rich ASP.NET controls?

With the CreateUserWizard as an example, there are ways of making it behave properly in terms of the HTML it renders but when do you draw the line? The CSS Friendly Control adapters are a very useful development, but when they affect the behaviour of a component and introduce quite a lot more complexity is it worth the cost?

What have I gained? In this case with the Membership/Profile providers, it would be quite easy to develop a bespoke control.

Any thoughts?

Leave a Reply

Your email address will not be published. Required fields are marked *