tags:

views:

90

answers:

4

Greetings.

Is there a good way to determine what is calling my Page_Load method? I've got a few Componentart WebUI grids that call it, although I've checked all of those (using the gridName.IsCallback property). I've also got an update panel, but I'm not sure how to check if it is the caller.

I'm betting there is a property somewhere that will tell me.

Thanks!

A: 

I'm not sure if there's a property your program can check at run-time, but if you put in a break point and then check the stack in Visual Studio, that will probably give you enough information to figure out where it's coming from.

StriplingWarrior
Call stack is the same both times it gets called. I must be missing something silly..
Joe Behymer
I wonder if your your UpdatePanel has redundant (or overlapping) asyncpostbacktriggers?
StriplingWarrior
A: 

Request.Form["__EVENTTARGET"] might do the trick, it contains the ID of any control other than a regular button (buttons trigger 'normal' postbacks) that triggered a postback.

Colin
Correct, the marked answer uses this method as well as another method if this won't find us the solution.
Joe Behymer
A: 

What could cause it is controls AutoPostBack property just check controls that you have on the page and see which one has that property set One of them did it.

grobartn
+1  A: 

Check out this blog post for GetPostbackControl.

JP Alioto
Excellent, thanks.
Joe Behymer