Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1958618
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T08:22:50+00:00 2026-05-17T08:22:50+00:00

Related to this question: On postback, how can I check which control cause postback

  • 0

Related to this question: On postback, how can I check which control cause postback in Page_Init event

If the control is wrapped in an ASP.NET AJAX UpdatePanel, the variable “control” is empty because it has a different ID after the AJAX PostBack.
Is there a solution to get the control which fired a postback within an ASP.NET Ajax UpdatePanel?

public static string GetPostBackControlName( Page page ) {
        Control control = null;

        /**
         * First we will check the "__EVENTTARGET" because if the postback is made
         * by controls which used the _doPostBack function, it will be available in the Request.Form collection.
         */
        string ctrlname = page.Request.Params["__EVENTTARGET"];

        if ( !String.IsNullOrEmpty( ctrlname ) ) {
            control = page.FindControl( ctrlname );
        } else {
            /**
             * If __EVENTTARGER is null, the control is a button-type and
             * need to iterate over the form collection to find it.
             */
            Control c = null;
            string ctrlStr = null;

            foreach ( string ctl in page.Request.Form ) {
                if ( ctl.EndsWith( ".x" ) || ctl.EndsWith( ".y" ) ) {
                    /**
                     * ImageButtons have an additional "quasi-property" in their ID which identifies
                     * the mouse-coordinates (X and Y).
                     */
                    ctrlStr = ctl.Substring( 0, ctl.Length - 2 );
                    c = page.FindControl( ctrlStr );
                } else {
                    c = page.FindControl( ctl );
                }

                if ( c is Button || c is ImageButton ) {
                    control = c;
                    break;
                }
            }
        }

        if ( control != null ) {
            return control.ID;
        }

        return string.Empty;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T08:22:51+00:00Added an answer on May 17, 2026 at 8:22 am

    Try the following method:

    public string GetAsyncPostBackControlID()
    {
        string smUniqueId = ScriptManager.GetCurrent(Page).UniqueID;
        string smFieldValue = Request.Form[smUniqueId];
    
        if (!String.IsNullOrEmpty(smFieldValue) && smFieldValue.Contains('|'))
        {
            return smFieldValue.Split('|')[1];
        }
    
        return String.Empty;
    }
    

    The above method uses the hidden field of the ScriptManager on page. Its value can be accessed on the server by searching for a form key with the UniqueID of the ScriptManager. The value in the hidden field is in the format [UpdatePanel UniqueID]|[Postback Control ID]. Knowing this information we can retrieve the ID of the control that initiated the asynchronous postback. And it works for submit buttons too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Related to this question , I decided to check the UDFs in my data
This question is related to this other question I recently asked... cf.net exception and
This question is related to this post but I don't see how I can
Related to this question: URL characters replacement in JSP with UrlRewrite I want to
Related to this question , what is the best practice for naming a mutex?
This question is related to this one , though I think I was a
[This question is somewhat related to this question , but the answers are not...]
Much related to this question , we have a scenario on my team where
This is related to this question . I'm writing a Flex app (a WindowedApplication)
This is related to this question . I'm not an expert on Linux device

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.