From now on I will take my own advice.  I spent a good part Friday afternoon and Monday morning trying to figure out what was wrong with my code and I don’t want to do that again!  The problem I was having was that I had an ASP.Net control that would not postback, no matter what I tried.

I have a page with several user controls on it.  One of these user controls includes an asp:Textbox that is hooked to some JavaScript so that when the use clicks “enter” in that control a postback will occur.  The postback is accomplished by some JavaScript that calls the click event on a button that is hidden (style=”display:none”).  But the postback wouldn’t work.  I put a few alerts in the JavaScript and I knew it was getting called, but the postback still never occurred.  The problem was not so easy to see.  That’s because I had a second user control on the page.  That second user control has an asp:RequiredFieldValidator in it.  To complicate things, that validation control was tucked in a modal popup (using the Ajax Control Toolkit’s Modal Popup Extender).  But, I forgot to include the ValidationGroup property on the validator.  So any control on the page would cause validation to occur which will block the postback if validation fails.  But since the validator was in the popup (which of course, was not currently popped up), I didn’t see the error message that was trying to tell me there was a problem.

The problem was easily fixed (if not easily found) by simply adding the ValidationGroup property to the validator and of course, matching it up on the button that is supposed to call that validation group.  Since the hidden button on my other control was not included in the same validation group, it was free to postback any time it wants.

A cool thing happened at work today.  Dean was stuck trying to figure out how to get the EditItem from an asp:Listview.  So he hits his favorite search engine to look for an answer.  Believe it or not, the first item in the search result was a link to a post on my blog!  Dean got his answer.  But I thought that was the coolest thing that he his answer could have come from anywhere in the world but he searched and got a post from the guy sitting right across from him!