Websforms want jQuery confirm after button clicked

Charles Baldo
Charles Baldo used Ask the Experts™
on
Hi

I have a web form that a user is entering hours worked. When the user presses the button

<asp:Button ID="cmdSubmit" CausesValidation="true" runat="server" Text="Submit Hours" OnClick="cmdSubmit_Click" />

I would like a jQuery box to ask if the hours that have been tallied and put in this put in this textbox

<asp:TextBox ID="TotalHours"  CssClass="data-input"  ClientIDMode="Static" runat="server" />

to appear and ask if the value in this textbox are correct.  If the user chooses "Yes" I want the dialogbox to go on and execute the event at

OnClick="cmdSubmit_Click"
 
 if not I want the event to not happen
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Software Engineer
Top Expert 2009
Commented:
Use OnClientClick event and return true to execute server event otherwise false.
<asp:Button ID="cmdSubmit" CausesValidation="true" runat="server" Text="Submit Hours" OnClick="cmdSubmit_Click" OnClientClick="return callMethod();" />
<script type="text/javascript">
    function callMethod() {
       //logic prior dialog goes here
       $('#TotalHours').val('Set your new value here')
        return confirm('Your message here asking yes/no') == true;
}
</script>

Open in new window

Charles BaldoSoftware Developer

Author

Commented:
Excellent

Thanks again Miguel

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial