title: UserControl with UpdatePanel programmatically create ScriptManager possible?
body: <p>I'd like to use an UpdatePanel in my UserControl. The problem is the .aspx page the control is dropped on will NOT have a ScriptManager. I will need to create the ScriptManager in the UserControl. However if the UserControl is used, say twice on the page, then placing a ScriptManager won't work because you can only initialize ScriptManager once.</p>
  
  <p>In other UserControls where I needed ScriptManager (I was using AJAX Toolkit Extensions) I was able to use this code:</p>
  
  <pre><code>protected override void OnInit(EventArgs e)
  {
      base.OnInit(e);
      Page.Init += new EventHandler(Page_Init);
  }
  
  void Page_Init(object sender, EventArgs e)
  {
      if (Page.Form != null &amp;&amp; ScriptManager.GetCurrent(Page) == null)
          Page.Form.Controls.AddAt(0, new ScriptManager());
  }
  </code></pre>
  
  <p>..worked great, but not for the UpdatePanel case.</p>
  
  <p>Note, I am NOT using Master Pages</p>
  
  <p>(Another approach I was thinking of, but can't figure out how to do, is to programmatically create the UserControl inside an UpdatePanel.)</p>