Wednesday, August 18, 2010

How to avoid event calling when refresh from browser?

i have asp.net form with some data on datagrid, i have written


ondeletecommnad event of datagrid to remove single row data


it works fine


but the problem is whenever i delete record from last row of datagird on ondeletecommnad event , it fires, then i refresh browser either by f5 or button, then event does not fires again





But whenever i delete record from any row except than last row of datagird on ondeletecommnad event , it fires, then i refresh browser either by f5 or button, then event again fires





I checked it by Debugging the applicationHow to avoid event calling when refresh from browser?
In the first line of your page load, try this:





If NOT Postback then





with the END IF at the end of the page load.





It should only run the event the first time you hit the page in a Session. If you hit it again or 'post back' to the same page the IF statement skips that event.

No comments:

Post a Comment