Reputation: 199
I want to add a confirmation message on button click , but btnUpdateEmail_Click
not working now.
<asp:Button ID="btnSave" runat="server" UseSubmitBehavior="false"
Text="Update Import Email" ValidationGroup="groupValidation"
OnClientClick="return confirm('Are you sure you want to update
Import Email?');" OnClick="btnUpdateEmail_Click"
CssClass="btn-danger" Height="46px" Width="237px"
Font-Bold="true" />
Upvotes: 1
Views: 636
Reputation: 3247
Using UseSubmitBehavior="true" nearly did the trick. Be sure to have your OnClientClick
call set up correctly:
Code was using OnClientClick="return Validate();"
which is incorrect. It should just be
<asp:Button ID="keyword" runat="server" Text="Search" TabIndex="1"
OnClick="keywordSearch_Click" OnClientClick="if (!Validate()) { return false;};" />
If it is set up incorrectly, the OnClick
function will not fire.
Also click here, for more.
Also you can find, onclientclick-and-onclick-is-not-working-at-the-same-time.
Upvotes: 1
Reputation: 678
You have to only change the value of UseSubmitBehavior from false to true.
I hope it will resolve your problem.
<asp:Button ID="btnSave" runat="server" UseSubmitBehavior="true" Text="Update Import Email" ValidationGroup="groupValidation" OnClientClick="return confirm('Are you sure you want to update Import Email?');" OnClick="btnUpdateEmail_Click" CssClass="btn-danger" Height="46px" Width="237px" Font-Bold="true" />
Upvotes: 1