ASP.Net controls not firing postback event

When you add an ASP.Net control like button, linkbutton, combobox etc. you expect that when you will click on this control, the page will cause a post back and you will be handling server side event handler for click on that control. Sometime you run into an issue when postback event does not fired. The clicking on control does not do anything. You get the feeling that no event is getting fired. There are only couple of reasons that can cause postback to not fire.

The least like cause can be that there is some client side javascript code that is cancelling event bubbling for your click event to respond. This is something that is highly unlikely because if you have some very custom implementation like this, then you are probably aware of it.

Most likely cause is that you have a control validator on the page and validation conditions are not satisfied when you are clicking on that control. And this problem becomes more cryptic when you forgot to add any visual indicator or error that tells you about validation condition violation. Here is another obvious cause of this problem. If you have a tab control on the page and one or more of the tabs have validation control(s). And then you are on tab that does not validation control. So you try to click on some control that has to cause PostBack. Now the problem is that although you are on different tab, but validators from other tabs are still part of the page. So before postback occurs, page is going to try to validate those validators. And if for some reason any of those validators fail, then postback action is cancelled.

So if you are running into this postback issue because of validators on tabs, then you need to handle tab switching event and then enable or disable those validators depending on your application rules etc.

comments powered by Disqus

Search

Social

Weather

18.5 °C / 65.2 °F

weather conditions Clear

Monthly Posts

Blog Tags