I am writing code that mimics the effect of sending to a page, executing exactly the same web request that will be generated when a button is clicked, which starts the postback of the page.
The problem is that the response from the web request does not match what I get when I click on the button.
When checking, I see that even when the Page_Load event is triggered and processed when the web request is executed, the handler for clicking the button is not executed (this means that either the event is not triggered or it is triggered but not processed - I assume that this is probably the first happening).
So my question is , how does ASP.NET know which button was pressed so that it could invoke the appropriate handler?
I thought this was done using the __EVENTTARGET parameter - I set it correctly in the body of the web request email, but it didn’t matter.
I looked at the decoded __VIEWSTATE argument, but I could not see anything obvious there.
Can anyone help?
EDIT: To be clear, I am not asking how to add a click handler to a web application.
Rather, I'm looking at an application that already has a button click event handler running, and I want to know how asp.net calculates from an incoming web request which button code intercepts the call event handler code.
source
share