What's hot ? (and I mean really ...) - scroll down for more
1).  Code Templating - advanced usage of delegates & generics: my slides & demos are available for download! CodeProject article is also available.

2).  My series "TDD in the eyes of a simpleminded" is in progress(including code!): preface, part1, part2, Q&A 1, Manual Stub .vs. Mock Stub

3).  TDD Workshop: SeeCompass v0.1 and v0.2 are out.
# Thursday, May 24, 2007

I had just resolved a very ugly bug in one of our screens. The behavior was the following:
You open a the page and click on a "cancel" button that closes the current screen and refresh the parent screen.
So far all is sweet.
Now you do it again (open & click "cancel")
So far all is sweet.
Try to open any other page.
gosh! nothing works! Everything got stuck somehow...

The cancel button was declared like this:

<asp:Button id="..." runat="server" OnClientClick="RefreshParentAndCloseMe();" />


Can you spot the problematic approach here?
Button.AutoPostBack is set to True as default which means that clicking on the button triggered page submit but at the same
time we run javascript code to close the window. My guess is that the server gets a new request and handles it but the client
is dead until then(until the response is ready).
Playing with this behavior can lead to unexpected behavior (in our case - we had to close the browser and start over)

Solutions?
  A. Use html button (I prefer this one as this pure client behavior button)
  B. change the OnClientClick to: OnClientClick="RefreshParentAndClose(); return false;"
  C. Set AutoPostBack=False on the button.

Posted by Oren Ellenbogen 
24/05/2007 10:14, Israel time UTC+03:00,     Comments [4]  | 
Thursday, May 24, 2007 2:53:37 PM (Jerusalem Standard Time, UTC+02:00)
very nice tip
thanx
Dror Engel
Saturday, May 26, 2007 2:25:51 AM (Jerusalem Standard Time, UTC+02:00)
Sweet webforms.
They're just so fun to use.

Seriously, I vote for A, for the same reason you wrote
Tuesday, June 05, 2007 2:54:29 PM (Jerusalem Standard Time, UTC+02:00)
Boogie!

you aren't going to believe !- we add a new instance of this pitfall.

even we had a "return false;" on button OnClientClick event, we fall again!

how?! - because we also add onunload event oo the page.
and this event call some server side code (via button event click) while the window was already close - this case us the pitfall.

Cheers man,
Ran
Ran
Tuesday, June 05, 2007 10:38:33 PM (Jerusalem Standard Time, UTC+02:00)
damn dude,
so much pain :)

Thanks for tha heads up though!

Oren.
Comments are closed.