65.9K
CodeProject is changing. Read more.
Home

Who caused postback?

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Oct 11, 2013

CPOL
viewsIcon

5743

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

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
        }
    }