Hi, Mark. Thanks for the response.
That I know and employ all of it.
Page_Load usually has code to restore state and application data (like
customer information which involves one or more DB round trips), restoring
user controls, etc. There are situations where I do not want such code to
execute when certain controls are clicked because it would be wasteful.
I have modularized functionality into functions and subs and call them in
certain controls' events, but I am looking for a different approach.
Thanks again,
Mike
"Mark Rae [MVP]" <> wrote in message
news:%...
> "milop" <> wrote in message
> news:...
>
>> Using .Net 2.0 and above, how,in the Page_Load event, can I determine
>> what control triggered the postback?
>
> As Patrice said, you can inspect the __EVENTARGET form field.
>
> However, you should really think carefully about why you think you need to
> know this in the Page_Load event...
>
> E.g. if you have an asp:Button webcontrol, when you click it it will cause
> a postback and then its Click event will fire - this is where you will
> write anything which needs to happen when this button is clicked, and the
> Page_Load event should never need to know about it specifically.
>
> Alternatively, if e.g. you had ten asp:Button webcontrols all of which did
> almost the same thing, then you would wire them all up to use the same
> server-side event, maybe a Command event, and then set a value in each
> webcontrols CommandArgument property which could be inspected server-side
> in order to branch the code as required...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net