Avoiding PostBack on a Dropdown Click

A Typical search function has a few textboxes and a SEARCH Button, Since a search functionality is not the fastest moving planet in the galaxy of functionalities, many a times the user would modify the exisiting search criteria and click on the SEARCH button again. To avoid such a situation add a JavaScript to the SEARCH button and check for the following condition before proceeding with the POSTBACK
if(document.readyState != ‘complete’)

The same problem can be faced when using two DROP-DOWN Controls with POSTBACK for every Selection. To avoid a postback for a dropdown when a post back for another dropdown is in progress, The following javascript needs to be added for both the dropdown controls before proceeding with the Postback.

drpRegistrationType.Attributes.Add("onchange","
if(document.readyState != ‘complete’)
");

NOTE: Don’t put
semicolon at the end of if statement as .Net puts its own script for AUTOPOSTBACK.



Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s