BreakHead
BreakHead

Reputation: 10672

How to display a Message Box and get confirmation YES or NO from aspx.cs

I need to dispaly a message box for confirmation to delete an Item or not but not sure how to do that if I use javascript alert, than how will I get confirmation??

Upvotes: 2

Views: 3115

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

You could use the confirm function:

if (confirm('Are you sure you want to delete this item?')) {
    // TODO : the user confirmed
}

As you've tagged your question with ASP.NET:

<asp:LinkButton 
    ID="DeleteButton" 
    runat="server"
    CommandName="Delete" 
    Text="Delete"
    OnClientClick="return confirm('Are you sure you want to delete this item?');" 
/>

Upvotes: 5

Related Questions