Implement a Message Box to confirm an Asp.Net server control event

Tuesday, 9 June 2009 15:45 by myro

You just need to provide a simple Message box that asks for confirmation when a button is clickked? There are several ways to accomplish this, but if you don't need a complicated solution consider in adding a small javascript to the Asp.Net control on the OnClientClick attribute:

<asp:ImageButton ID="imbdelete"
         OnClientClick="return confirm('Are you sure you want to delete this configuration?');"
         runat="server" CausesValidation="false"
         ImageUrl="~/_layouts/Images/DELETE.GIF" OnClick="imbdelete_click" />

A message box will be prompted when users clicks this Imagebutton, which will raise the postback only if the 'yes' button is pressed. Cool..

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   .NET | Web
Actions:   Bookmark and Share | Permalink | Comments (1) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.

Comments