Home / ASP.NET Wiki / Security / Input and Data Validation / Who caused postback?

Who caused postback?

 Rate It (0)

How to check if a specific control caused postback?

Let's say you have a button ( btnAdd ) among other controls...

To check if it has just caused postback, place the next code in Page_Load event handler:

    protected void Page_Load(object sender, EventArgs e)
    {
        // If button btnAdd is clicked
        if (Request.Params.ToString().IndexOf("btnAdd") > 0)
        {
            // do something here
        }
        else
        {
            // do something else
        }
    }

Revision number 1, Monday, June 16, 2008 7:16:12 AM by marko.pa
This is not the most up to date version of this article. The most recent version can be found here.

Comments

nice

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)