Using jCarousel Lite With ASP.Net

Don't break the keyboard!

After almost two hours of debugging a contact form built in C# and ASP.Net, something fairly trivial to do, I almost broke another keyboard. I was trying to get the client side validators to work (another trivial process), but nothing I did was working.  The validators would incorrectly (or correctly dependending on how you look at this) invalidate the form and disallow my form submission.  So, I stripped out all of the validators except for the empty field validators, still the problem refused to go away. For the life of me I couldn't understand why they invalidated the form even when correct input was given.

After about 20 minutes, I removed all of the validators from the page and what came next was unexpected. I noticed that each time I invoked a post back to the server, the text boxes were filling with commas. My first thought was that I had a broken script or html tag on the page - that wasn't it. I then opened FireFox and watched the document before and after postback and I found the problem - jCarousel Lite plug-in for jQuery. The skinny of it is this: I created 5 content slides, but when jCarousel initializes, there are now 11 - not sure why, but a nice plug-in just took a big hit in the word-of-mouth department.

For whatever reason, the plug-in creates clones of the "slides", I suppose to make it more fluid, but nonetheless troublesome.  ASP.Net disallows elements with the same id and now we know what happens if you have two text boxes with the same id when you post back.  It takes the values from all controls with the same id's and joins their values separated with a comma. Posting back to the server will continually append and join the "double id" text boxes, giving you values like this: ",,,,,,,,,,"

First there was one, then there were two, then...

The solution, or work-around, was to remove my contact form from the slide rotation (for the time being), not ideal - but i'm sick of looking at it for now. 

#1 Peter McBride on 2.01.2010 at 9:46 AM

Nice post. I had the same issue, but removed the slide component completely.

Now I can reinstall this plug-in.

Thanks!