How to handle Cancel button in Confirm() method?

Discussion in 'ASP .Net' started by lakshmikandhan@gmail.com, Apr 4, 2006.

  1. Guest

    Hi All,

    Can anyone tell how to handle the Cancel button in the
    JavaScript Confirm() method?If we press cancel, I have to perform
    certain action in the Server side? Plz help me!!

    Thanx,
    Jacob.
     
    , Apr 4, 2006
    #1
    1. Advertising

  2. Guest

    Hi Eliyahu,

    Thanx for ur response.Can u explain the above concept by an
    simple example??? Plz give me some code samples!!
     
    , Apr 4, 2006
    #2
    1. Advertising

  3. Jacob,

    Cancel button click causes the confirm dialog to close with return value
    false. All this is taking place on client-side. You will need to communicate
    an info to the server side. Most standard way of doing this is using hidden
    input elements. You can cause the page to postback from JavaScript by
    calling the form's submit() method.

    Eliyahu

    <> wrote in message
    news:...
    > Hi All,
    >
    > Can anyone tell how to handle the Cancel button in the
    > JavaScript Confirm() method?If we press cancel, I have to perform
    > certain action in the Server side? Plz help me!!
    >
    > Thanx,
    > Jacob.
    >
     
    Eliyahu Goldin, Apr 4, 2006
    #3
  4. on client:
    if(!confirm("...")){
    myForm..value="CANCELED";
    myForm.submit();
    }

    in .aspx file:
    <input type=hidden id=inhMessage runat=server>

    in the code-behind (c#):
    in the Page_Load event:
    if (IsPostBack())
    {
    if (this.inhMessage.Value == CANCELED")
    {
    // do something
    }
    }

    Eliyahu


    <> wrote in message
    news:...
    > Hi Eliyahu,
    >
    > Thanx for ur response.Can u explain the above concept by an
    > simple example??? Plz give me some code samples!!
    >
     
    Eliyahu Goldin, Apr 4, 2006
    #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. JerryK

    confirm does not cancel postback?

    JerryK, Mar 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,489
    JerryK
    Mar 22, 2005
  2. Jane
    Replies:
    1
    Views:
    270
    kaeli
    Feb 23, 2004
  3. Tasha's Dad

    Need to cancel a javascript alert/confirm box

    Tasha's Dad, Nov 4, 2004, in forum: Javascript
    Replies:
    5
    Views:
    316
    kaeli
    Nov 9, 2004
  4. Indu
    Replies:
    9
    Views:
    359
  5. FAQ server
    Replies:
    4
    Views:
    502
    Evertjan.
    Mar 7, 2007
Loading...

Share This Page