I have a JS Method as follows: ( I don’t know if it’s 100% correct)
<script Type="Text/Javascript">
if (confirm("Are you SUre ?")) {
return true;
} else {
return false;
}
</script>
And have some doubts:
First: I have a folder called JS and i’m planing to put it there, is this correct?
Second: I will use this on an Edit page, so when the customer clickon the button edit I’d like this confirmation with some message like "Are you Sure? and the buttons Yes/No
If the customer clicks on the Yes then i’ll keep with my edit on database.
So how do I do that ? How I call this method at the moment that the customer click on the ImageButton ?
One more thing: How Do I get the return of this method and work with it on my aspx.cs using C#?
I tried the code below, but didn’t work =\ it shows me the popUp but even when I click cancel it goes to the OnClick Method
<asp:ImageButton ID="Btn_Alterar" runat="server" ImageUrl="~/Imgs/btAlterar.jpg" OnClick="Btn_Alterar_Click" OnClientClick="confirm()" />
This should work. It will pop up the question and if they say yes then will process the server side code (as an example).
JS:
ASP.NET Control:
.CS
Edit: (with thanks to @justnS)
Another implementation would be:
ASP.NET Control:
The above is exactly the same as the previous implementation but takes less code and is done inline.