Question

Using the code posted as answer at this question, it is possible to find the control that caused the postback action.

However, it is possible to check which event was called by this control? For example, identify an editing event fired by a GridView before the equivalent method (editing) be executed.

Thanks in advance.

Was it helpful?

Solution

It depends if the client code is providing this information. The standard GridView, for example, sets both __EVENTTARGET and __EVENTARGUMENT when a sort header link is clicked:

Request.Form["_EVENTTARGET"] contains "ctl00$MainContent$GridView1" Request.Form["_EVENTARGUMENT"] contains "Sort$id"

where the __EVENTARGUMENT contains information that this is a Sort operation, and the column to be sorted on, separated by $.

For paging the __EVENTARGUMENT value looks similar:

Request.Form["__EVENTARGUMENT"] contains "Page$2"

Note though that not all controls populate __EVENTARGUMENT on postback, so you'll have to test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top