title: ASP.Net Web User Control methods and events not available in code-behind of host page
body: <p>I needed a validation tool that could be reused in multiple projects, so I decided to make it a Web User Control. Below are the steps I took to set it up:</p>
  
  <ul>
  <li>Created a new web project and added my Web User Control.</li></li>
  <li>In IIS, I enabled the project as an application, and set this new project folder as a Virtual Directory in all the projects that will be using it, and enabled each Virtual Directory as an application.</li>
  <li><p>For each project that uses the control, I added a reference to the dll, and added the control to that project's <code>web.config</code>:  </p>
  
  <pre><code>&lt;add tagPrefix="ut" src="~/UserControls/ValidateAcct.ascx" tagName="ValidateAcct" /&gt;
  </code></pre>
  
  <p>NOTE: <code>'UserControls'</code> is a Virtual Directory, and does not actually exist in each of the host projects.</p></li>
  <li><p>Then I added the control to the host page:</p>
  
  <pre><code>&lt;ut:ValidateAcct ID="valAcct" runat="server" /&gt;
  </code></pre></li>
  </ul>
  
  <p>At runtime the content from the Web User Control displays correctly on the host page, but from the host page's code-behind I am unable to call any of the methods I created for the Web User Control. If I instantiate the control entirely from code-behind, the methods are there. I assume this is because I am working solely from the dll, and doesn't involve any Virtual Directory.</p>
  
  <p>Another issue I am encountering is with events. I created the following event on the Web User Control, and I'd like to handle it on my host page:</p>
  
  <pre><code>    protected virtual void AccountValidated(object sender, EventArgs e) { }
  </code></pre>
  
  <p>Once again, from the host page's code-behind I cannot access this event. I thought maybe I could just instantiate the control in the code-behind to access the event, like I did with the methods, but even that didn't work.</p>
  
  <p>The goal here is that I'd like this user control to be used by multiple projects within one website, but only have to maintain one copy of the control/code. This is why I went the Virtual Directory route, but I have a feeling this is the cause of all my problems. Any assistance anyone can give would be greatly appreciated!</p>