ChiBella
asked on
ModalPopupExtender Reuse
How can a ModalPopupExtender custom messagebox be reused within an aspx page? I have several panels that require separate update buttons (separate message text and command parameters) all within one page. I want to be able to use the same control for all panels.
Can this be done? The ModalPopupExtender and panel are within an updatepanel.
Can this be done? The ModalPopupExtender and panel are within an updatepanel.
After reading your question again, I think you may want to use the same extender for all three buttons? I do not think this can be done unless you extend the modal control yourself. My example uses three modal extenders but only one panel.
ASKER
Yes, I am trying to use the same extender for all three buttons.
I think I can do this...but I'm stuck on how to pass a javascript parameter from a button to the label(s) I want displayed within the popup and the command argument and name I want to pass to the server depending upon which button is pressed.
I think I can do this...but I'm stuck on how to pass a javascript parameter from a button to the label(s) I want displayed within the popup and the command argument and name I want to pass to the server depending upon which button is pressed.
javascript:
function ShowModalPopup()
{
var mpe = $find('ModalPopupExtender1');
if (mpe) {
mpe.show();
}
}
.....
one of the buttons calling the javascript
.....
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnASave" cssClass="centerButton" runat="server" Text="Button A Text" OnClientClick="ShowModalPopup(buttonA parameter?)" />
</ContentTemplate>
</asp:UpdatePanel>
.....
Single Modalpopup outside of the panels containing the buttons that call the javascript function
.....
<asp:UpdatePanel ID="UpdatePanelPopSave" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblPopTest" runat="server" Text="Start"></asp:Label>
<%-- <asp:Button ID="btnPopSave" runat="server" Text="Open MessageBox" />--%>
<asp:LinkButton ID="btnPopSave" runat="server" style="display: none;" ></asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="btnPopSave"
PopupControlID="PanelPopSave"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="CancelButton"
BehaviorID="ModalPopupExtender1" >
</cc1:ModalPopupExtender>
<asp:Panel ID="PanelPopSave" runat="server" CssClass="modalPopup" Style="display: none" Width="350px">
<p class="modalPopupTitle">
<asp:Label ID="lblPopupTitleAddress" runat="server" ></asp:Label> Button Specific Text Here Save Options</p>
<input id="RadioSavePop" name="Radio" runat="server" type="radio" />
<label for="RadioSavePop">Save Only!</label><br />
<input id="RadioSaveProm" name="Radio" runat="server" type="radio" />
<label for="RadioSaveProm"Need Button Specific Text here!</label><br />
<br />
<div align="center">
<asp:Button ID="Ok" runat="server" Text="OK" OnClick="Save" CommandArgument = "BUTTONX" CommandName="BUTTONXUpdate" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I created a quick sample form with 3 textboxes, 3 buttons, 3 ConfirmButtonExtenders, and 3 ModalPopupExtenders each in their own separate panel. I also have the modal panel outside of the other three panels. All of this is in one update panel. All three use only one popup panel. This appears to work just fine. Please let me know if this is not what you wanted. I have inlcuded both the web code and code behind in the snippet so you can test. I have also included the classes from the css that I am using.
Open in new window