title: updatepanel and javascript include file
body: <p>I have found many solution for my issue but none doesn't work in my scenario.
  I have created a test project to demo my concept.</p>
  
  <p>Basically, there is a page that host a user control...</p>
  
  <pre><code>&lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
  &lt;/asp:ScriptManager&gt;
  &lt;div&gt;
      &lt;uc1:WebUserControl1 ID="WebUserControl11" runat="server" /&gt;
      &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /&gt;
      &lt;br /&gt;
      &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>WebUserControl1 has a dropdownlist and two other webusercontrols (to be displayed based on the selection of dropdownlist element) inside updatepanel as below.</p>
  
  <pre><code>&lt;%@ Register Src="WebUserControl2.ascx" TagName="WebUserControl2" TagPrefix="uc2" %&gt;
  &lt;%@ Register Src="WebUserControl3.ascx" TagName="WebUserControl3" TagPrefix="uc3" %&gt;
  &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
  &lt;ContentTemplate&gt;
      &lt;asp:DropDownList ID="DropDownList1" runat="server"                
            OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
          AutoPostBack="True"&gt;
      &lt;/asp:DropDownList&gt;
      &lt;asp:Panel ID="pnlCreditCard" Visible="false" runat="server"&gt;
          &lt;uc2:WebUserControl2 ID="WebUserControl21" runat="server" /&gt;
      &lt;/asp:Panel&gt;
      &lt;asp:Panel ID="pnlGiftCard" Visible="false" runat="server"&gt;
          &lt;uc3:WebUserControl3 ID="WebUserControl31" runat="server" /&gt;
      &lt;/asp:Panel&gt;
  &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>Code behind file for WebUserControl1 is .....</p>
  
  <pre><code>        public enum PaymentMethod
      {
          CreditCard = 0,
          GiftCard
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {
          if (!Page.IsPostBack)
              BindPaymentMethods(Enum.GetValues(typeof(PaymentMethod)));
      }
  
      private void BindPaymentMethods(Array paymentMethods)
      {
          DropDownList1.DataSource = paymentMethods;
          DropDownList1.DataBind();
  
          if (paymentMethods.Length &gt; 0)
          {
              DropDownList1.SelectedIndex = 0;
              UpdateCreditOrGiftCardPanelVisibility();
          }
      }
  
      protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
      {
          UpdateCreditOrGiftCardPanelVisibility();
      }
  
      private void UpdateCreditOrGiftCardPanelVisibility()
      {
          if(DropDownList1.SelectedValue == Enum.GetName(typeof(PaymentMethod),PaymentMethod.CreditCard))
          {
              pnlGiftCard.Visible = false;
              pnlCreditCard.Visible = true;
          }
          else if (DropDownList1.SelectedValue == Enum.GetName(typeof(PaymentMethod), PaymentMethod.GiftCard))
          {
              pnlCreditCard.Visible = false;
              pnlGiftCard.Visible = true;
          }
      }
  </code></pre>
  
  <p>Now, the problem starts here...There is an external javascript file [JScript1.js] (embedded resource) which basically is used to display an alert box.</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  
  window.onload = function() {
      alert('creditcard form');
  }
  </code></pre>
  
  <p></p>
  
  <p>WebUserControl2.ascx.cs code behind is</p>
  
  <pre><code>        protected void Page_Load(object sender, EventArgs e)
      {
          ScriptManager.RegisterClientScriptInclude(this.Page, this.Page.GetType().BaseType, "JScript1", Page.ClientScript.GetWebResourceUrl(this.Page.GetType().BaseType, "WebApplication1.JScript1.js"));
      }
  </code></pre>
  
  <p>Alert window doesn't get displayed when I change the dropdownlist value. Even the script is getting registered three times (look in the firebug)
  Need to use ScriptInclude instead of ScriptBlock as the original JS file is too big.</p>
  
  <p>Can email the test app....</p>
  
  <p>Thanks in Advance</p>