Call JavaScript Function from Code Behind #2
<p>I have one web control (called <code>A</code>) and one web page (Called <code>Default</code>).  </p>

<p>Is there a way to call a JavaScript function from <code>Default</code> that belongs to <code>A</code> instead of using <code>OnClientClick</code>?  </p>

<p>I am using the following in <code>Page_Load</code> of <code>Default.aspx.cs</code> (This is where my JavaScript function is coming from): </p>

<pre><code>a = (A)LoadControl("~/A.ascx");
a.ID = "AgControl";
panel.Controls.Add(a);
</code></pre>

<p>In Default.aspx I have the following: </p>

<pre><code>&lt;asp:Button ID="Button1" runat="server" Text="Button" 
OnClick="Button1_OnClick"
OnClientClick="JavaScript()"  /&gt;
</code></pre>

<p>DefaultPage.aspx.cs:</p>

<pre><code>protected void Button1_OnClick(object sender, EventArgs e)
   {
  String a = getValueofA();

  If (a == "1")
  {
            //OnClientClick code goes here
  }
  else If (a == "2")
  {
     //No OnClientClick code goes here
  }
 }
</code></pre>

<p>My goal is to remove <code>OnClientClick="JavaScript()</code> and code it only in the first part of the "if statement".  </p>
