Button updates its own OnClientClick and then executes that?
<p>I am a .NET newb so please bear with me.</p>

<p>I am working on an online store.  It requires the visitor to choose quantities they want and then click a button to choose a date for those items (tours).  </p>

<p>I have two buttons - one reads their choices and updates the OnClientClick value of the other and when that one is clicked it executes a popup.  The project requires me to do the whole process with just one button.  Here's the rough outline of the particulars:</p>

<p>Setup button:</p>

<pre><code>    //Calculates parameters to send to popup based on control contents.
    public void btnSetup_Click(object sender, EventArgs e)
    {
        StringBuilder sbParams = new StringBuilder();
        TotalQty += basketItem.Quantity;                    
        Sku = variant.Sku;                          
        sbParams.Append(string.Format("?sku={0}&amp;Qty={1}",Sku.Substring(0,4),TotalQty));

        popup = string.Format("window.open('http://somesite.ocm/cal.asp{0}','Reservation Calendar','width=265,height=465')",sbParams.ToString());
    btnCalendar.OnClientClick = popup;
     }
</code></pre>

<p>Calendar button:</p>

<pre><code>    // Shows popup via OnClientClick
    public void btnCalendar_Click(object sender, EventArgs e)
    {
        AddPopup.Show();
    }
</code></pre>

<p>It works fine as a two-step process, click Setup and then click Calendar buttons.  If I move the setup code into the calendar routine it fails.  I'm sure this is because the Calendar button's OnClientClick is not set when it is clicked.</p>

<p>What is a best-practices type of way to do this without restructuring the whole program.  As I'm new to .NET programming I don't want to wreck the thing.</p>
