0

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

2
  • How you are sending information to the server? As you have 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. Commented Jun 19, 2023 at 7:23
  • You call the function from the onclick event so it returned the answer to the event dispatch and not where you want it ( i am a c# expert but in js it works like that) try and separate it Commented Jun 19, 2023 at 7:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.