• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

button javascript confirm

I have an asp button.
<asp:button id="SaveButton" runat="server" 
text="Save" onClientClick="GetInput()" onclick="SaveButton_Click" />

Open in new window

As you can see I call GetInput() function. In it I need to create a confirm message. If the user selects Yes then the rest of the function should be executed and postback made, otherwise the postback should be cancelled

How is best to do this?
0
johnkainn
Asked:
johnkainn
  • 2
1 Solution
 
Ramkisan JagtapLead DeveloperCommented:
Add onClientClick="return confirm('Are you you want to save tis record?')"  to you button code as below.
<asp:button id="SaveButton" runat="server"
text="Save" onClientClick="return confirm('Are you you want to save tis record?')" onclick="SaveButton_Click" />
0
 
Ramkisan JagtapLead DeveloperCommented:
if doesnot work add ; at the end
<asp:button id="SaveButton" runat="server"
text="Save" onClientClick="return confirm('Are you you want to save tis record?');" onclick="SaveButton_Click" />
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Your GetInput javascript method must be something like:
<script type="text/javascript">
    function GetInput() {
        return confirm('Ok?');
    }
</script>

Open in new window


And your aspx code:
<asp:button id="SaveButton" runat="server" 
text="Save" onClientClick="return GetInput()" onclick="SaveButton_Click" />

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now