<p>I'm fairly new to ASP.NET and trying to learn how things are done. I come from a C# background so the code-behind portion is easy, but thinking like a web developer is unfamiliar.</p>

<p>I have an aspx page that contains a grid of checkboxes. I have a button that is coded via a Button_Click event to collect a list of which rows are checked and create a session variable out of that list. The same button is referenced (via TargetControlID) by my ascx page's ModalPopupExtender which controls the panel on the ascx page.</p>

<p>When the button is clicked, the modal popup opens but the Button_Click event is never fired, so the modal doesn't get its session data.</p>

<p>Since the two pages are separate, I can't call the ModalPopupExtender from the aspx.cs code, I can't reach the list of checkboxes from the ascx.cs code, and I don't see a way to populate my session variable and then programmatically activate some other hidden button or control which will then open my modal popup.</p>

<p>Any thoughts?</p>

[{'answer_id': 12676, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Sorry, but I'm confused. You can't call an ascx directly, so...</p>\n\n<p>Is your modal code that you are calling from within the same page, like a hidden panel, etc; </p>\n\n<p>Or is it another aspx page that you are calling on a click event?</p>\n"}, {'answer_id': 12700, 'author': 'DancesWithBamboo', 'author_id': 1334, 'author_profile': 'https://Stackoverflow.com/users/1334', 'pm_score': 3, 'selected': True, 'text': "<p>All a usercontrol(.ascx) file is is a set of controls that you have grouped together to provide some reusable functionality.  The controls defined in it are still added to the page's control collection (.aspx) durring the page lifecylce.  The ModalPopupExtender uses javascript and dhtml to show and hide the controls in the usercontrol client-side.  What you are seeing is that the click event is being handled client-side by the ModalPoupExtender and it is canceling the post-back to the server.  This is the default behavior by design.  You certainly can access the page's control collection from the code-behind of your usercontrol though because it is all part of the same control tree.  Just use the FindControl(xxx) method of any control to search for the child of it you need.</p>\n"}, {'answer_id': 14735, 'author': 'Erick B', 'author_id': 1373, 'author_profile': 'https://Stackoverflow.com/users/1373', 'pm_score': 1, 'selected': False, 'text': '<p>After some research following DancesWithBamboo\'s answer, I figured out how to make it work.<br>\nAn example reference to my ascx page within my aspx page:</p>\n\n<pre><code>&lt;uc1:ChildPage ID="MyModalPage" runat="server" /&gt;\n</code></pre>\n\n<p>The aspx code-behind to grab and open the ModalPopupExtender (named modalPopup) would look like this:</p>\n\n<pre><code>AjaxControlToolkit.ModalPopupExtender mpe = \n    (AjaxControlToolkit.ModalPopupExtender) \n          MyModalPage.FindControl("modalPopup");\nmpe.Show();\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/12671', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1373/']