Confirm Delete Message

Discussion in 'ASP .Net' started by Greg Smith, Jun 2, 2005.

  1. Greg Smith

    Greg Smith Guest

    What is the best way to present a "Confirm Delete" message to a user and get
    the response back?

    Any help is greatly appreciated.
    Greg Smith, Jun 2, 2005
    #1
    1. Advertising

  2. Greg Smith

    Steph Guest

    Hi,

    One possible way is to create a button and on the code-behind (click
    event...):
    YourButton.Attributes.Add("onclick", "javascript: return confirm('Are u sure
    ?');");

    ++
    Steph, Jun 2, 2005
    #2
    1. Advertising

  3. A client-side onclick event.

    This sets up the server-side OnClick event handler:
    <asp:Button id=btnDelete runat=server OnClick=MyServerSideHandler ... >

    And this sets up its client-side counterpart (c#):
    btnDelete.Attributes["onclick"] = "return confirm('Please confirm
    delete');";

    If the user doesn't confirm, no server event will be fired.

    Eliyahu

    "Greg Smith" <> wrote in message
    news:%...
    > What is the best way to present a "Confirm Delete" message to a user and

    get
    > the response back?
    >
    > Any help is greatly appreciated.
    >
    >
    Eliyahu Goldin, Jun 2, 2005
    #3
  4. Here's some server side code that uses javascript to display a confirmation
    message.

    myDeleteButton.Attributes.Add("onclick", _
    "return confirm('Are you sure you want to delete?');")

    In this example, the Delete button will post back only if the person
    confirms they want to delete. Otherwise your server code is never called in
    response to the button click.

    Here's a more detailed analysis of your options, including a free control
    that can handle many of the options for you.
    http://SteveOrr.net/articles/ClientSideSuite.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net

    "Greg Smith" <> wrote in message
    news:%...
    > What is the best way to present a "Confirm Delete" message to a user and
    > get the response back?
    >
    > Any help is greatly appreciated.
    >
    Steve C. Orr [MVP, MCSD], Jun 2, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Calvin Lai
    Replies:
    4
    Views:
    7,940
    Calvin Lai
    Feb 4, 2004
  2. Spongebob
    Replies:
    2
    Views:
    493
    Spongebob
    Feb 11, 2004
  3. Sandy
    Replies:
    1
    Views:
    7,222
    =?Utf-8?B?TWF1cmljaW9ERw==?=
    Jun 11, 2004
  4. Dexter
    Replies:
    2
    Views:
    503
    Dexter
    Oct 3, 2004
  5. Saravana
    Replies:
    1
    Views:
    523
    =?Utf-8?B?UHN5Y2hv?=
    Oct 4, 2004
Loading...

Share This Page