Working on a .net web application project and utilizing ConfirmButtonExtender
for confirmation. My goal is to validate all required fields first, then display a confirm message to the user conditionally.
Here is the code snippet:
<asp:Button ID="UpdatebuttonUpdaterID" runat="server"
Text="Update" CssClass="create_role_button_in"
OnClick="UpdatebuttonUpdaterID_Click" ClientIDMode="Static"/>
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender3"
runat="server" TargetControlID="UpdatebuttonUpdaterID"
ConfirmOnFormSubmit="true" BehaviorID="updateBehavior"
ClientIDMode="Static" DisplayModalPopupID="ModalPopupExtender3"/>
<asp:ModalPopupExtender ID="ModalPopupExtender3" runat="server"
TargetControlID="UpdatebuttonUpdaterID"
PopupControlID="Panel3" OkControlID="Button5"
CancelControlID="Button6" ClientIDMode="Static" >
</asp:ModalPopupExtender>
<asp:Panel runat="server" ID="Panel3" Style="display: none; width: 200px; background-color: White; border-width: 2px; border-color: Black; border-style: solid; padding: 20px;">
Do you want to send this Conversion Rate for Approval?<br />
<asp:Button runat="server" ID="Button5" Text="OK" />
<asp:Button runat="server" ID="Button6" Text="Cancel" />
</asp:Panel>
Javascript function:
Sys.Application.add_load(wireEvents);
function wireEvents() {
var behavior = $find("confirmBehavior");
if (behavior != null) {
behavior.add_showing(OnClientClickApprove);
}
var updateBehavior = $find("updateBehavior");
if (updateBehavior != null) {
updateBehavior.add_showing(OnClientClickUpdate);
}
}
function OnClientClickUpdate() {
if (some condition)
return false;
}
If the result of OnClientClickUpdate
is false, the confirm message should not be displayed to the user. Only when it returns true, the user should see the confirmation message on the UI.