display confirm message box for action

Discussion in 'ASP .Net' started by Grey, Sep 6, 2004.

  1. Grey

    Grey Guest

    how to design confirm message box, like Javascript Confirm box, in ASP.NET??
    if the user click "YES" in the confirm box, i need to do something, else do
    other things. Do I need to have javascript confirm box or ASP.NET has such
    feature??


    Million thanks.
     
    Grey, Sep 6, 2004
    #1
    1. Advertising

  2. Grey

    Mark Rae Guest

    "Grey" <> wrote in message
    news:...

    > how to design confirm message box, like Javascript Confirm box, in
    > ASP.NET??
    > if the user click "YES" in the confirm box, i need to do something, else
    > do
    > other things. Do I need to have javascript confirm box or ASP.NET has such
    > feature??


    For client-side user interaction, use JavaScript.
     
    Mark Rae, Sep 6, 2004
    #2
    1. Advertising

  3. for example:
    create a button: button1
    Page_Load():
    this.Button1.Attributes.Add("onclick","javascript:if(confirm('No to
    cancel?')== false) return false;");

    if "Cancel" button pressed, this page will not post back.


    "Grey" wrote:

    > how to design confirm message box, like Javascript Confirm box, in ASP.NET??
    > if the user click "YES" in the confirm box, i need to do something, else do
    > other things. Do I need to have javascript confirm box or ASP.NET has such
    > feature??
    >
    >
    > Million thanks.
    >
    >
    >
     
    =?Utf-8?B?SGFuZGk=?=, Sep 6, 2004
    #3
  4. Grey

    Greg Burns Guest

    Just to add to this.

    You can ONLY cancel the post back with javascript like this, you cannot
    branch and "do other things".

    Greg

    "Handi" <> wrote in message
    news:...
    > for example:
    > create a button: button1
    > Page_Load():
    > this.Button1.Attributes.Add("onclick","javascript:if(confirm('No to
    > cancel?')== false) return false;");
    >
    > if "Cancel" button pressed, this page will not post back.
    >
    >
    > "Grey" wrote:
    >
    >> how to design confirm message box, like Javascript Confirm box, in
    >> ASP.NET??
    >> if the user click "YES" in the confirm box, i need to do something, else
    >> do
    >> other things. Do I need to have javascript confirm box or ASP.NET has
    >> such
    >> feature??
    >>
    >>
    >> Million thanks.
    >>
    >>
    >>
     
    Greg Burns, Sep 6, 2004
    #4
  5. Grey

    Hans Kesting Guest

    "Handi" <> wrote in message news:...
    > for example:
    > create a button: button1
    > Page_Load():
    > this.Button1.Attributes.Add("onclick","javascript:if(confirm('No to
    > cancel?')== false) return false;");
    >
    > if "Cancel" button pressed, this page will not post back.
    >
    >


    Just a note: don't change the javascript to the seemingly identical but shorter
    return confirm('No to cancel?')
    because .Net can add it's own javascript to that onclick handler. This shorter
    version would prevent the execution of that code! This is also why you *need*
    the closing ";" to separate your code from the additional code.

    By the way, you don't need to specify "javascript:" for an onclick handler.

    Hans Kesting


    > "Grey" wrote:
    >
    >> how to design confirm message box, like Javascript Confirm box, in ASP.NET??
    >> if the user click "YES" in the confirm box, i need to do something, else do
    >> other things. Do I need to have javascript confirm box or ASP.NET has such
    >> feature??
    >>
    >>
    >> Million thanks.
    >>
    >>
    >>
     
    Hans Kesting, Sep 6, 2004
    #5
  6. Grey

    Greg Burns Guest

    I've never seen that recomendation before. Is it related to the classic
    "validator ate my onclick event" problem?

    one example of problem:
    http://tinyurl.com/6bkvw

    Greg


    > Just a note: don't change the javascript to the seemingly identical but
    > shorter
    > return confirm('No to cancel?')
    > because .Net can add it's own javascript to that onclick handler. This
    > shorter
    > version would prevent the execution of that code! This is also why you
    > *need*
    > the closing ";" to separate your code from the additional code.
    >
    > By the way, you don't need to specify "javascript:" for an onclick
    > handler.
    >
    > Hans Kesting
     
    Greg Burns, Sep 6, 2004
    #6
  7. Is it possible to have button text as Yes/No instead of OK/Cancel ??

    "Greg Burns" wrote:

    > I've never seen that recomendation before. Is it related to the classic
    > "validator ate my onclick event" problem?
    >
    > one example of problem:
    > http://tinyurl.com/6bkvw
    >
    > Greg
    >
    >
    > > Just a note: don't change the javascript to the seemingly identical but
    > > shorter
    > > return confirm('No to cancel?')
    > > because .Net can add it's own javascript to that onclick handler. This
    > > shorter
    > > version would prevent the execution of that code! This is also why you
    > > *need*
    > > the closing ";" to separate your code from the additional code.
    > >
    > > By the way, you don't need to specify "javascript:" for an onclick
    > > handler.
    > >
    > > Hans Kesting

    >
    >
    >
     
    =?Utf-8?B?TGVl?=, Sep 7, 2004
    #7
  8. Grey

    Greg Burns Guest

    AFAIK, not with a javascript confirm. Maybe using vbscript msgbox...?

    Greg

    "Lee" <> wrote in message
    news:...
    > Is it possible to have button text as Yes/No instead of OK/Cancel ??
    >
    > "Greg Burns" wrote:
    >
    >> I've never seen that recomendation before. Is it related to the classic
    >> "validator ate my onclick event" problem?
    >>
    >> one example of problem:
    >> http://tinyurl.com/6bkvw
    >>
    >> Greg
    >>
    >>
    >> > Just a note: don't change the javascript to the seemingly identical but
    >> > shorter
    >> > return confirm('No to cancel?')
    >> > because .Net can add it's own javascript to that onclick handler. This
    >> > shorter
    >> > version would prevent the execution of that code! This is also why you
    >> > *need*
    >> > the closing ";" to separate your code from the additional code.
    >> >
    >> > By the way, you don't need to specify "javascript:" for an onclick
    >> > handler.
    >> >
    >> > Hans Kesting

    >>
    >>
    >>
     
    Greg Burns, Sep 7, 2004
    #8
    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. Padam Jain
    Replies:
    1
    Views:
    1,290
    Anatoly
    Jul 14, 2003
  2. hamsinii

    dropdown confirm message box

    hamsinii, Jul 6, 2006, in forum: .NET
    Replies:
    0
    Views:
    624
    hamsinii
    Jul 6, 2006
  3. Padam Jain

    How to popup confirm message box in asp.net

    Padam Jain, Jul 14, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    903
    Anatoly
    Jul 14, 2003
  4. Padam Jain

    How to popup confirm message box in asp.net

    Padam Jain, Jul 14, 2003, in forum: ASP General
    Replies:
    2
    Views:
    302
    Bob Barrows
    Jul 14, 2003
  5. Replies:
    1
    Views:
    125
    Peter Michaux
    Mar 20, 2008
Loading...

Share This Page