I want to take confirmation from the user to Submit the form or not.
If the user Selects yes, The Submit button should be disabled & the Text should become "Please Wait" until the server side code is executed through C#.
C# code should only be executed if the user selects Yes in the Confirmation Popup.
I have tried the Following Javascript Code:
function confirmSubmit(element)
{
if (confirm('Are you Sure?'))
{
element.disabled = true;
element.value = 'please wait ...';
return true;
}
else
{
return false;
}
}
I have called the JS Method on Button click like this:
<asp:Button runat="server" ID="btn_Submit" Text="Submit Time Sheet" CssClass="btn mybtn confirmbtn" Width="100%" OnClick="btn_Submit_Click"
OnClientClick="return confirmSubmit(this);" UseSubmitBehavior="false"
/>
It works till the Disable but return does not work
UseSubmitBehavior="false"which will prevent the form submission (if you have a form) You need to submit the form or use your servers API to send the data to the server.