title: ASP.Net User Control not working when added at run time
body: <ol>
  <li>I have simply created a user control in asp.net which has a textbox,calendar and a button.
  <ol>
  <li>On the click event of that button i am making the calendar visible,and on the calendar's <code>onselectionchanged</code> event i am passing the selected date to the textbox.</li>
  <li>Now i have a .aspx page in which i am adding this user control at RUN TIME.</li>
  <li>The user control gets added,but the click event of the button by which i am making the calendar visible is not getting fired.</li>
  </ol></li>
  </ol>
  
  <p>What is the Issue? Its working fine when i add that user control at design time.
  But when i add it at run time in not working.</p>
  
  <p>
  &lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="Dates.ascx.cs" Inherits="Date"%>
        
  
  </p>
  
  <pre><code>//created a public object named 'users' of control class
  public partial class View_now : System.Web.UI.Page
  {
  public Control users;  
  }
  
  //loaded the user control in page load event
  protected void Page_Load(object sender, EventArgs e)
  {  
      users = LoadControl("~\\Dates.ascx");
  }
  
  
  //applied the user control to a panel
  protected void Button2_Click(object sender, EventArgs e)
  {
      Panel2.Controls.Add(users);
  }
  </code></pre>
  
  
  
  <p>Now when i click the usercontrol's button,the click event doesn't fire.</p>