Wednesday, October 22, 2008

PostBack Events are not firing in asp.net................Why????????

This seems to be a problem with all the beginners at one or the other moment in their coding profession they face this problem.

One of the silly mistake due to which this problem can occur is that you have some validation controls on your page which you are initialy not showing up on the page ie there might be a situation wherein you might have various divs on a page and you might be using tabbed navigaiton to show one particular div's contents at one time and hiding rest of the div's.So sometimes you might have some validation controls in one particular div and you might be working on the contents of another div which doesnot have any validation controls but do have postback controls ie asp controls.

But what happens in this situation is that although the divs are hidden yet the markup is processed and loaded on the page now if you click on any postback buttons or linkbuttons or any control to do postback it will not postback because you have not met the required validation fulfilment reuqirements as the text boxes which you are using for validation might be empty or there might be some other problem in there which is causing validation to be false, thus no postback to the server.

So if such is your scenario then just enter a property of the asp control called "CausesValidation" to false.

Setting this will remove that button from checking that are the validation requirements fulfilled on the page and thus it will cause a postback.

4 comments :

Rem said...

Your blog is very nice...
visit my blog asp.net example

Aashish said...

Thanks Rem, i visited your blog you have a lot of cool stuff on yours too.

Anonymous said...

I have been struggling with this for the past two days before coming across this post. It worked for me.

Thank you for your help.

Anonymous said...

still not working with button/imagebutton within div

Post a Comment