There will be some scenarios where we may have to identify the sender that caused the async postback(While using update panel) . Normally we will try to identify the control by checking the sender element . This wont be always giving the correct value as multiple clicks/ elements under the update panel can alter this. We can identify the control that caused an async postback by sending the ID of the control along with the request as user context. You can use the following script for this.
<script>
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
try {
args.get_request().set_userContext(args.get_postBackElement().id);
}
catch (e) {
}
}
function EndRequestHandler(sender, args) {
try {
if (args.get_error() == undefined) {
var sName = args.get_response().get_webRequest().get_userContext();
if (sName == "btnDetails") {
}
else {
}
}
}
catch (e) {
}
}
</script>