SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Apologies if this is a pretty basic question but I'm a relative SharePoint newbie and I've been trying to find an answer for this for a couple of days.

I have an SPToolBarButton that provide Delete functionality via its OnClick. However, I need to prompt the users with an 'Are you sure?' Yes/No modal dialog box.

I have attempted to use OnClientClick="return confirm('Are you sure?')" but can't find a way of picking up the user's selection from within my code-behind page.

Is this even the correct approach to use?

Thanks for reading.

share|improve this question

If the user clicks "Cancel" in the confirm then it will return false and the postback cancelled.

Since there is no postback then the code-behind doesn't actually run - so no check of which button clicked is needed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.