Click here to Skip to main content
Click here to Skip to main content

Ajax: Identify the control that caused the Async Postback

By , 12 Jan 2010
Rate this:
Please Sign up or sign in to vote.
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.
	function BeginRequestHandler(sender, args) {
            try {
            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) {


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

J a a n s
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

GeneralThanks, I really don't need it yet but I am sure this is goi... PinmemberAzerax13-Sep-11 23:18 
Thanks, I really don't need it yet but I am sure this is going to be useful someday Big Grin | :-D .
GeneralNice one... thanks. PinmemberRavishankar Visvan27-Jul-11 3:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 12 Jan 2010
Article Copyright 2010 by J a a n s
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid