Answered by:
Stop modalpopup until i click yes or no

Question
-
User-862757099 posted
dear sir
I have created a messagebox using the ajax modalpopup
But when i show the modalpopup i want it to stay and do not execute the code which are written after the line where i am using modalpopup.show();
And when user click yes or no on the modalpopup it executes the line afterward bcos the input which user gives on that modalpopup decides what to do next
Thanks please replyTuesday, April 28, 2015 1:29 PM
Answers
-
User2103319870 posted
But when i show the modalpopup i want it to stay and do not execute the code which are written after the line where i am using modalpopup.show();
And when user click yes or no on the modalpopup it executes the line afterward bcos the input which user gives on that modalpopup decides what to do nextYou can show the modal popup from server side and then based on the button click events which you have in the modal popup execute the codes accordingly.
Please try the below implementation:
Add dummy button in your HTML MarkUp like given below
<asp:Button ID="btnDummy" runat="server" Text="Edit" Style="display: none;" />
Assign it to your modalpopup extender
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnDummy" PopupControlID="PnlModal" BackgroundCssClass="modalBackground"> </asp:ModalPopupExtender>
Reason for this modalpopupextender always a need a TargetConrolId associated with it , other wise you will get exception.
Now you can open the popup from page load like given below
Complete Code:
<style type="text/css"> .modalBackground { background-color: Gray; filter: alpha(opacity=70); opacity: 0.7; } .modalPopup { background-color: SkyBlue; border-width: 3px; border-style: solid; border-color: Black; padding: 3px; width: 100px; height: 100px; } </style> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnDummy" PopupControlID="PnlModal" BackgroundCssClass="modalBackground"> </asp:ModalPopupExtender> <asp:Button ID="btnDummy" runat="server" Text="Edit" Style="display: none;" /> <%--The below panel will display as your confirm window--%> <asp:Panel ID="PnlModal" runat="server" Width="500px" CssClass="modalPopup"> Are you sure want to Continue?<br /> <asp:Button ID="Button3" runat="server" Text="OK" onclick="Button3_Click" /> <asp:Button ID="Button4" runat="server" Text="Cancel" onclick="Button4_Click" /> </asp:Panel>
C#:
protected void Page_Load(object sender, EventArgs e) {
//You can use the below code to show where ever you want to show the Modal Popup ModalPopupExtender1.Show(); } protected void Button4_Click(object sender, EventArgs e) { ModalPopupExtender1.Hide(); //call Your Function or code if you select Cancel option } protected void Button3_Click(object sender, EventArgs e) { ModalPopupExtender1.Hide(); //call Your Function or code if you select OK option }- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 28, 2015 2:01 PM -
User-862757099 posted
I guess u didnt understand my point.
I have code after modalpopup.show() which is
If aa == 1 then
Else
it execute these codes also and then show modalpopup
I want it to stop at modalpopup.show(); and then when i click button it goes forward
Bcos in btnyes its just setting value of aa to 1 nothing else
Actually my modalpopup is in masterpage and i m using a common modalpopup for all my webfforms
I hope now u have understand my problem..
Regards- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 28, 2015 2:23 PM -
User1644755831 posted
Hello zaigham_ali,
If aa == 1 then
Else
it execute these codes also and then show modalpopupit should not matter if your modalpopup extender is in the master page. what A2H is describing is that you use callbacks instead of stopping the execution you should redefine the structure of your code so that the execution of the your code does not stop but your code is executed after you close the model popup in this case after you click OK or cancel like A2H suggested. Hope I am clear enough.
With Regards,
Krunal Parekh
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, April 30, 2015 3:44 AM
All replies
-
User753101303 posted
Hi,
Which one exactly? More likely rather than to "pause" execution, you should be able to define the code that should run when one button from this message box is clicked...
Tuesday, April 28, 2015 1:57 PM -
User2103319870 posted
But when i show the modalpopup i want it to stay and do not execute the code which are written after the line where i am using modalpopup.show();
And when user click yes or no on the modalpopup it executes the line afterward bcos the input which user gives on that modalpopup decides what to do nextYou can show the modal popup from server side and then based on the button click events which you have in the modal popup execute the codes accordingly.
Please try the below implementation:
Add dummy button in your HTML MarkUp like given below
<asp:Button ID="btnDummy" runat="server" Text="Edit" Style="display: none;" />
Assign it to your modalpopup extender
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnDummy" PopupControlID="PnlModal" BackgroundCssClass="modalBackground"> </asp:ModalPopupExtender>
Reason for this modalpopupextender always a need a TargetConrolId associated with it , other wise you will get exception.
Now you can open the popup from page load like given below
Complete Code:
<style type="text/css"> .modalBackground { background-color: Gray; filter: alpha(opacity=70); opacity: 0.7; } .modalPopup { background-color: SkyBlue; border-width: 3px; border-style: solid; border-color: Black; padding: 3px; width: 100px; height: 100px; } </style> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnDummy" PopupControlID="PnlModal" BackgroundCssClass="modalBackground"> </asp:ModalPopupExtender> <asp:Button ID="btnDummy" runat="server" Text="Edit" Style="display: none;" /> <%--The below panel will display as your confirm window--%> <asp:Panel ID="PnlModal" runat="server" Width="500px" CssClass="modalPopup"> Are you sure want to Continue?<br /> <asp:Button ID="Button3" runat="server" Text="OK" onclick="Button3_Click" /> <asp:Button ID="Button4" runat="server" Text="Cancel" onclick="Button4_Click" /> </asp:Panel>
C#:
protected void Page_Load(object sender, EventArgs e) {
//You can use the below code to show where ever you want to show the Modal Popup ModalPopupExtender1.Show(); } protected void Button4_Click(object sender, EventArgs e) { ModalPopupExtender1.Hide(); //call Your Function or code if you select Cancel option } protected void Button3_Click(object sender, EventArgs e) { ModalPopupExtender1.Hide(); //call Your Function or code if you select OK option }- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 28, 2015 2:01 PM -
User-862757099 posted
I guess u didnt understand my point.
I have code after modalpopup.show() which is
If aa == 1 then
Else
it execute these codes also and then show modalpopup
I want it to stop at modalpopup.show(); and then when i click button it goes forward
Bcos in btnyes its just setting value of aa to 1 nothing else
Actually my modalpopup is in masterpage and i m using a common modalpopup for all my webfforms
I hope now u have understand my problem..
Regards- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 28, 2015 2:23 PM -
User1644755831 posted
Hello zaigham_ali,
If aa == 1 then
Else
it execute these codes also and then show modalpopupit should not matter if your modalpopup extender is in the master page. what A2H is describing is that you use callbacks instead of stopping the execution you should redefine the structure of your code so that the execution of the your code does not stop but your code is executed after you close the model popup in this case after you click OK or cancel like A2H suggested. Hope I am clear enough.
With Regards,
Krunal Parekh
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, April 30, 2015 3:44 AM -
User753101303 posted
More specifically try http://stackoverflow.com/questions/8079674/jquery-ui-alert-dialog-as-a-replacement-for-alert
The point is that you don't (and likely can't) stop execution. Instead you are using callbacks to tell what to do when the event you want happens (button click, window closed etc...)
Thursday, April 30, 2015 4:11 AM