title: Only one instance of a ScriptManager can be added to the page in asp.net
body: <p>When I'm trying to add user control I got this error</p>
  <blockquote>
  <p>Only one instance of a ScriptManager can be added to the page</p>
  </blockquote>
  <p>Code:</p>
  <p>.ascx</p>
  <pre><code>&lt;%@ Control Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;VisaUserControl.ascx.cs&quot; Inherits=&quot;Portal.VisaUserControl&quot; %&gt;
  &lt;%@ Register Assembly=&quot;BasicFrame.WebControls.BasicDatePicker&quot; Namespace=&quot;BasicFrame.WebControls&quot; TagPrefix=&quot;dp&quot; %&gt;
  &lt;asp:ScriptManager ID=&quot;scriptmanager1&quot; runat=&quot;server&quot;&gt;&lt;/asp:ScriptManager&gt;
  &lt;div id=&quot;divreg&quot; runat=&quot;server&quot;&gt;
  &lt;table id=&quot;tbl&quot; runat=&quot;server&quot;&gt;
      &lt;tr&gt;
      &lt;td&gt;
          &lt;asp:Label ID=&quot;lbl2&quot; runat=&quot;server&quot;&gt;&lt;/asp:Label&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt; Visa Number:&lt;/td&gt;
  &lt;td&gt;&lt;asp:TextBox ID=&quot;txtUser&quot; Width=&quot;160px&quot; runat=&quot;server&quot;/&gt;&lt;/td&gt;
  &lt;td&gt; Country Name:&lt;/td&gt;
  &lt;td&gt;&lt;asp:DropDownList ID=&quot;dropCountry&quot; Width=&quot;165px&quot; runat=&quot;server&quot;&gt;&lt;/asp:DropDownList&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt; Type of Visa:&lt;/td&gt;
  &lt;td&gt;&lt;asp:DropDownList ID=&quot;dropVisa&quot; Width=&quot;165px&quot; runat=&quot;server&quot; OnSelectedIndexChanged=&quot;dropVisa_SelectedIndexChanged&quot;&gt;&lt;/asp:DropDownList&gt;&lt;/td&gt;
  &lt;td&gt; Type of Entry:&lt;/td&gt;
  &lt;td&gt;&lt;asp:DropDownList ID=&quot;dropEntry&quot; Width=&quot;165px&quot; runat=&quot;server&quot;&gt;&lt;/asp:DropDownList&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt; Expiry Date&lt;/td&gt;
      &lt;td&gt;&lt;asp:TextBox ID=&quot;txtDate&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt;
          &lt;ajaxToolkit:CalendarExtender ID=&quot;CalendarExtender1&quot; runat=&quot;server&quot; 
                            TargetControlID=&quot;txtDate&quot; PopupButtonID=&quot;Imgbtnfromdate&quot; Format=&quot;dd/MM/yyyy&quot;&gt;
                        &lt;/ajaxToolkit:CalendarExtender&gt;
      &lt;/td&gt;
  &lt;td&gt;
  &lt;asp:Button ID=&quot;btnRemove&quot; Text=&quot;Remove&quot; runat=&quot;server&quot; OnClick=&quot;btnRemove_Click&quot; /&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  <p>.aspx.cs</p>
  <pre><code>  protected override void LoadViewState(object savedState)
      {
          base.LoadViewState(savedState);
  
          GenerateControls();
      }
  
  
  
      private void GenerateControls()
      {
          foreach (string i in NoOfControls)
          {
              VisaUserControl ctrl = (VisaUserControl)Page.LoadControl(&quot;VisaUserControl.ascx&quot;);
              ctrl.ID = i;
              this.rpt1.Controls.Add(ctrl);
          }
      }
  </code></pre>
  <p>Here is the problem</p>
  <pre><code>    protected void btnAddVisa_Click(object sender, EventArgs e)
      {
  
          List&lt;string&gt; temp = null;
          var uc = (VisaUserControl)this.LoadControl(@&quot;VisaUserControl.ascx&quot;);
  
          string id = Guid.NewGuid().ToString();
          uc.ID = id;
  
          temp = NoOfControls;
          temp.Add(id);
          NoOfControls = temp;
          rpt1.Controls.Add(uc);
      }
  </code></pre>
  <p>In the below image if I click the Add button, I get the error:</p>
  <p><img src="https://i.stack.imgur.com/02hEp.png" alt="enter image description here" /></p>