title: Controlling a modalpopup from multiple buttons to show different charts
body: <p>I would like to present several buttons on a page that each pop up a different chart.  I used a modalpopup for the first one, and I'm looking for an efficient way to manage the rest.  While I could create separate modalpopups for each chart, that seems very wasteful.  I'm using C#.</p>
  
  <p>Is there a way to have each of these buttons use the same modalpopup but run separate functions in codebehind to bind the chart differently?  Or is there a completely different approach that would work for this?</p>
  
  <p>Thanks.</p>
  
  <p>Edit: Adding Code Sample (scrubbed)</p>
  
  <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt;
  
  &lt;asp:ImageButton ID="ImageButton1" 
                style="padding-left:12px;" 
                runat="server"
             ImageUrl="images/chart_icon.png" 
              onclick="ImageButton1_Click" /&gt;
  
  &lt;asp:Panel ID="Panel2" 
          runat="server" 
         Height="350px"  
          Width="700px" 
       CssClass="modalPopup" 
      BackColor="#122b7c" 
    BorderColor="#3366FF" 
    BorderStyle="Solid" 
    BorderWidth="1px" 
        Visible="false"&gt;
  
  &lt;div align="center" style="padding-top:10px;"&gt;
  
      &lt;asp:Chart ID="Chart2" 
              runat="server" 
             Height="300px" 
              Width="690px" 
            Visible="false"
   ImageStorageMode="UseImageLocation"&gt;
  
      &lt;Series&gt;&lt;/Series&gt;
      &lt;ChartAreas&gt;&lt;/ChartAreas&gt;
  
      &lt;/asp:Chart&gt;
  
  &lt;/div&gt;
  &lt;div align="center"&gt;
      &lt;asp:Button ID="btnModalCancel" 
               style="margin-top:10px;" 
               runat="server" 
                Text="Close" /&gt;
  &lt;/div&gt;
  
  &lt;asp:ModalPopupExtender ID="Panel2_ModalPopupExtender" 
                       runat="server"
          DynamicServicePath="" 
                     Enabled="True" 
             TargetControlID="ImageButton1"
          BackgroundCssClass="modalBackground" 
             CancelControlID="btnModalCancel"
                  DropShadow="true" 
              PopupControlID="Panel2"&gt;
  &lt;/asp:ModalPopupExtender&gt;
  
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>I looked at an answer where two separate buttons (like my ImageButton) were using JavaScript to trigger the onclick event of a hidden button, but I need to do some different code behind for each so I don't know if that works.  If I could trigger the hidden button click event from another button's onclick event in a way that the modalpopupextender recognized it and fired the popup to show I would be good.</p>