About the author

Steven HarmanSteven Harman is a passionate developer who believes that writing great software isn't just a job, its a craft.

ASP.NET MVP

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

devLINK Technical Conference

Jobs

Badges

  • Subtext Project
  • Support Subtext
  • HiddenNetwork.com Banner

CSS Control Adapters Cause Double PostBack in IE

As you might have been able to tell by my last few posts about CSS Friendly Control Adapters - I'm in the middle of using the adapters on a project... and I'm running into all kinds of trouble. I finally came to the realization that many of the issues I've seen are all caused by the same bit of busted functionality - a double PostBack.

I just posted a new message to the CSS Friendly Control Adapters Forum over at asp.net, and I figured I'd re-post it here in hopes of drawing a little more attention to the issue.

The Forum Post

Recently I've been trying to use CSS Adapters along with the Membership/Roles/Provider controls and I've come across an issue where the Adapters cause the page to PostBack twice when using IE. (I tested using IE7 and FF 2.0... but others have confirmed the issue exists in IE6 as well).

For example, when using the CreateUserWizard and it's Adapter, clicking the submit button (which kicks off the CreateUserWizardStep) causes the page to PostBack twice in a row.

From an end-user point of view an error message is displayed on the screen, and rightly so. By stepping through the code in debug mode, I was able to verify that the first PostBack successfully created a user (and the user shows up in the aspnet_Membership table). However when they wizard tries to create the user for the 2nd PostBack it fails because the user already exists. Hence, an error is thrown and shown to the user.

A similar situation occurs with the PasswordRecovery control - the password is actually reset twice, and two emails are sent to the user.

You can confirm the double PostBack using Fiddler.

  1. fire up Fiddler and go to a page using one of the above controls (and their respective Adapter of course).
  2. Use the control.
  3. Look in the Fiddler HTTP Sessions window and you'll see duplicate POST requests for the same page.

Others have reported the same issue, though they didn't root-cause it as being a double-PostBack issue. See here. The only solution I've found so far is to disable the Control Adapter for the CreateUserWizard and PasswordRecovery controls.

Oh, and I do apologize for coming off a bit rude in the other post(s)... it was late, I was tired and frustrated... but now I'm in a much better state of mind.

So, to recap:

  • using RTM version of CSS Adapters
  • using asp.net 2.0 Membership/Profile/Roles controls with CSS Adapters
  • Membership controls + CSS Adapters work fine with FF 2.0
  • some (possibly all?) Membership controls + CSS Adapters cause double PostBack with IE7 (and others have confirmed same issue with IE6).

Got any ideas?

Again, that was just a re-post of the forum post I made earlier... but if you have any ideas or input please don't hesitate to either leave a comment here or over at the original asp.net Forum post.

Update

I have now confirmed this to be a problem with the following controls:

  • CreateUserWizard
  • PasswordRecovery
  • ChangePassword

This leads me to believe that it is in fact an issue with the Adapters in general. The issue being: All of the Adapters are causing double PostBacks but only the controls listed above actually result in an error. The second PostBack causes the controls to throw errors because the control changed the state of the system in response the first PostBack.

What others are saying.

# CSS Control Adapters Cause Double PostBack in IE
Gravatar DotNetKicks.com
Apr 18, 2007
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Eber Irigoyen
Apr 19, 2007
very interesting problem, don't forget to post the solution or workaround, should you find any
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Steve Harman
Apr 19, 2007
@Eber: Don't worry, I fully intend to post any solution that I (or anyone else for that matter) comes up with.
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Remmus
Apr 19, 2007
I'm not sure if this is a help or not but I'm not experiencing the same problems using the Beta 2 version of the CSS adapters.
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Brian
Apr 19, 2007
It doesn't happen with all adapters. I did a quick test, and it didn't happen for the Menu (clicking a menu item), TreeView (clicking a tree item), or FormView (clicking a page number). Granted tests were limited, but at least it isn't all controls. :|
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Steve Harman
Apr 19, 2007
@Brian: Thanks for looking into some of the other Adapters and confirming that it's not an across the board issue. Perhaps it's just an issue with the Membership controls then?

Or even better (or worse...) maybe it is actually limited to just the controls I've listed above. Hopefully we'll get some clarification from the CSS Adapters and/or asp.net team soon.

Thanks again!
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Steve Harman
Apr 19, 2007
As mentioned in a recent post, the CSS Adapters have a new home - CodePlex!

Seeing as we (the community) now have access to the project I went ahead and opened a new issue in the project's issue tracker. So if you're suffering from this double postback issue, please go vote the issue up so it get noticed... and hopefully fixed. :)
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Brian
Apr 20, 2007
Remember, it's open source, so you can also investigate the issue and send us a patch to fix it, if you find a solution... Then again, you can send a patch to fix or add just about anything now that it's OSS.
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Steve Harman
Apr 21, 2007
@Brian: I've found a work-around for the double postback issue, but I've not gone public with it yet because I'm tracking down exactly why it makes it work. There is some funky Javascript vodoo going on with postbacks and I've got to get my head around it.

And I do intend to get involved with the CSSAdapters project and submit some code... of course, that is assuming you guys will let me into the club. :)

Actually, I was talking with Phil (Haacked) today on Skype and poking fun at him because of your comments on the Adapters CodePlex site about since you're Phil Haack, the rules don't apply, telling him he needs to watch it or he's going to float away b/c his head is getting so big. ha!
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Tana Isaac
Apr 21, 2007
Hi Steve,

I've just posted a solution for this at http://forums.asp.net/1676119/ShowThread.aspx#1676119 which should serve as an interim fix until the CSS Adapters team releases a new version.

Enjoy [:)],
Tana
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Steve Harman
Apr 21, 2007
@Tana: Great work!

In my reply to Brian (above) I mentioned that I was looking into a proposed fix, and I ended up coming to the same conclusion as you. However, I didn't come across the other issues you mentioned - good catch.

I also posted a comment to an open Work Item on this issue over at the CSS Adapters project at CodePlex. As soon as I hear back from them, I'll be putting a patch together (including the changes you've suggested) and submitting it.

Again, thanks for the great work and for keeping us all updated.

-Steve
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Martin
Feb 22, 2008
Hi Guys. Thanks heavens for this post, I thought I was cracking up! I can confirm the same thing is definitely happening in Firefox 2.0.0.12

It is also happening with the login control, Although you will be able to login ok, it wont redirect you to the destination page because of the double postback. I think the css friendly stuff should be integrated into ASP.NET anyway by now shouldn't it?

I will have a go at them solutions n see if I can get it workin - has anyone got a latest dll I can use?

Cheers Guys

Mart
# re: CSS Control Adapters Cause Double PostBack in IE
Gravatar Steven Harman
Feb 22, 2008
@Martin, AFAIK these issues were fixed some time ago, so my advice would be to pull down the latest bits from the CSS Friendly Adapters project site.
# Generic plavix.
Gravatar Plavix.
Aug 16, 2008
Generic plavix. Plavix. Plavix stroke. Plavix assistance program.
Comments have been closed on this topic.