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

  • Home
  • SEARCH
  • 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 4267272
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:52:37+00:00 2026-05-21T06:52:37+00:00

I am currently developing a web site using ASP.NET 3.5. On a page there

  • 0

I am currently developing a web site using ASP.NET 3.5. On a page there are some situations I don’t want that a specific control will cause a postback to the server. I wrote a function to return false if that condition is met which will be called when the onsubmit-Event occurs. But I somehow need to determine which control will cause the postback, because the postback should be cancelled only if this specific control caused it under certain conditions. How it is possible to do that?

Thanks for your time.

  • 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-21T06:52:37+00:00Added an answer on May 21, 2026 at 6:52 am

    See:

    How does ASP.NET recognize the control
    responsible for handling the postback?
    When no controls referenced in the
    request body implement the
    IPostBackEventHandler interface, the
    page class looks for the __EVENTTARGET
    hidden field, if any. The contents of
    the field is assumed to be the ID of
    the control that caused the postback.
    If this control implements the
    IPostBackEventHandler interface, the
    RaisePostbackEvent method is invoked.

    this is from here – The Client Side of ASP.NET Pages.

    So at the client-side __EVENTTARGET is all you need. At the server-side you could either override the Page.RaisePostBackEvent method (this is protected method, so you could inherit from System.Web.UI.Page class):

    protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, 
                                               string eventArgument)
    {
        // sourceControl is a control that caused postback
        base.RaisePostBackEvent(sourceControl, eventArgument);
    }
    

    or perform the same without inherining:

    var controlName = page.Request.Params["__EVENTTARGET"];
    Control postbackControl = null;
    if (!string.IsnullOrEmpty(controlName))
    {
        postbackControl = this.Page.FindControl(controlName);
    }
    

    EDIT: regarding the author’s comment to my answer: if __EVENTTARGET value is an empty string, it seems you’re getting this value before it is been set in __doPostBack function. So the workaround could be in overriding __doPostBack function or a similar way; you could find an example of doing it in this SO quesion.

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

Sidebar

Related Questions

Using ASP.Net Am New to website development Currently am developing a web pages, when
I'm currently developing a web application in ASP.Net with SQL Server and I would
I've recently been developing a website using asp.net webforms that uses in proc sessions
PHP newbie here. I'm currently developing a shopping cart web site using PHP and
I'm currently developing a tutorial site for teaching the fundamentals of Web development (HTML,
I am currently developing a Rails application using a database that was designed before
I'm currently developing a PHP application that's using an Access database as a backend.
I am currently developping an web site that require DateTime entry and I am
I am developing an application using asp.net 2.0 (C#), in which I am trying
I am developing an application using ASP.NET MVC 1 and VS2008. When I deploy

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.