User prompt handling

Discussion in 'ASP .Net' started by Thrud, Jan 5, 2004.

  1. Thrud

    Thrud Guest

    I have a button (runat=server) with some VB code attached
    to its on click event which does data updates.

    I now want to add a warning to the user prompting them
    whether they really want to perform the update. If they
    say Ok then the update proceeds, otherwise it is cancelled.

    How is the best way to do this? As far as I see the only
    way to get the prompt is to use the JScript Confirm
    function but to use this I need to turn off the
    runat=server flag which makes the button disappear.

    Any help would be much appreciated, Thrud
     
    Thrud, Jan 5, 2004
    #1
    1. Advertisements

  2. Thrud

    Curt_C [MVP] Guest

    couple ways...
    First is a simple CLIENT-SIDE confirm attached to the button.
    The other is what I have done. Two buttons. The first simply posts back and
    "un-hides" a confirm button while it "hides" the save button. The confirm
    button has the actual code to save the info to the DB, not the save button.
     
    Curt_C [MVP], Jan 5, 2004
    #2
    1. Advertisements

  3. Use:

    MyButton.Attributes.Add("onClick", "return confirm('Are you sure you want to
    continue with this update?')")

    Hope this helps,

    Mun
     
    Munsifali Rashid, Jan 5, 2004
    #3
  4. Thrud

    Ken McAndrew Guest

    Ken McAndrew, Jan 5, 2004
    #4
  5. Thrud

    Kikoz Guest

    Add this to your button in code behind:

    btn.Attributes["onClick"] = "alert('Something');"

    Or "confirm" - same thing, but use return.

    Regards.
     
    Kikoz, Jan 5, 2004
    #5
  6. Thrud

    Thrud Guest

    Thanks All, especially Munsifali,

    MyButton.Attributes.Add("onClick", "return confirm('Are
    you sure you want to
    continue with this update?')")

    works exactly how I want.
     
    Thrud, Jan 6, 2004
    #6
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.