Say you have a Button in your Web form, with OnClick bound to a code-behind event.
You then move that button up into the master page, by adding it to the Controls collection of a control in the master page. This is done at run-time, in the Page_Load event.
Where is the OnClick event bound to now? Still the code-behind of the Web form, or is it looking in the code-behind of the master page?
I did just this, and now my button doesn't do anything. It posts the page back, but doesn't actually run the bound event in the code-behind.
I checked the HTML of the button in both cases. The only thing that changed was the ID and the name, to reflect the change in naming container:
In the Web form ("MainContent" is a ContentPlaceholder):
<input type="submit" id="ctl00_MainContent_DeleteButton" value="Yes, Delete" name="ctl00$MainContent$DeleteButton"/>
In the master page:
<input type="submit" id="ctl00_DeleteButton" value="Yes, Delete" name="ctl00$DeleteButton"/>
I have run the debugger and can confirm that it's not touching the bound event any longer.
Is it the ID or the name that binds it to an event? If so, will my moving it into the master page break this binding?