Controlling a modalpopup from multiple buttons to show different charts
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#.
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?
Thanks.
Edit: Adding Code Sample (scrubbed)
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:ImageButton ID="ImageButton1"
style="padding-left:12px;"
runat="server"
ImageUrl="images/chart_icon.png"
onclick="ImageButton1_Click" />
<asp:Panel ID="Panel2"
runat="server"
Height="350px"
Width="700px"
CssClass="modalPopup"
BackColor="#122b7c"
BorderColor="#3366FF"
BorderStyle="Solid"
BorderWidth="1px"
Visible="false">
<div align="center" style="padding-top:10px;">
<asp:Chart ID="Chart2"
runat="server"
Height="300px"
Width="690px"
Visible="false"
ImageStorageMode="UseImageLocation">
<Series></Series>
<ChartAreas></ChartAreas>
</asp:Chart>
</div>
<div align="center">
<asp:Button ID="btnModalCancel"
style="margin-top:10px;"
runat="server"
Text="Close" />
</div>
<asp:ModalPopupExtender ID="Panel2_ModalPopupExtender"
runat="server"
DynamicServicePath=""
Enabled="True"
TargetControlID="ImageButton1"
Backgro开发者_如何转开发undCssClass="modalBackground"
CancelControlID="btnModalCancel"
DropShadow="true"
PopupControlID="Panel2">
</asp:ModalPopupExtender>
</asp:Panel>
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.
simple approach:
Think about using different charts in your modal popup that you hide or show based on the popup you're using.
advanced approach:
On big projects we use ajax to generate the content that is loaded into modal popups if we're using like images or shapes/charts.
How are you generating the charts?
精彩评论