Reputation: 136
1) I've an updatepanel in an aspx page containing a gridview and an asp.net button
2) The user select some griview's items and press the asp.net button to launch some CRUD stuff on the DB via code-behind.
3) Before to start this CRUD stuff a javascript alert must appear to ask: "are you sure to continue?"
4) When the user press "OK" on the alert then the code behind can continue to operate the CRUD stuff
I was able to implements the first three points, but I'm blocked on the fourth: how the hell I can trap in code behind the "OK" pressed in the alert javascript?
Can anyone help me?
Thank you very much.
Upvotes: 2
Views: 670
Reputation: 18113
What about you call confirm just 'before' you starting the crud?
To accomplish this, just include onClientClick="return confirm('Are you sure?');"
on the asp.net button.
As you asked here is a simple example using command:
ASP.NET
<asp:Button ID="cmdRegister" runat="server" Text="Register" OnCommand="cmdRegister_Command" OnClientClick="return confirm('Are you sure?');" CommandArgument="10"></asp:Button>
Code Behind:
protected void cmdRegister_Command(object sender, CommandEventArgs e)
{
int argument = Convert.ToInt32(e.CommandArgument);
if (argument == 10)
{
//somework
}
}
Upvotes: 2