Strange doubt javascript:confirm

Discussion in 'ASP .Net' started by Paulo Roberto, Aug 1, 2007.

  1. Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
    javascript:confirm('are you sure delete record?') on gridview at
    rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
    does nothing... but on my machine at HOME, even when I click cancel it
    deletes the records... It´s a very strange problem because to my knowledge
    it´s a client feature... What can be the problem ? IE versions ?

    Thanks!
     
    Paulo Roberto, Aug 1, 2007
    #1
    1. Advertising

  2. on my work machine works well, but on my home machine doesnt... both are XP
    PRO SP 2

    "Paulo Roberto" <> escreveu na mensagem
    news:%23Po%...
    > Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
    > javascript:confirm('are you sure delete record?') on gridview at
    > rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
    > does nothing... but on my machine at HOME, even when I click cancel it
    > deletes the records... It´s a very strange problem because to my knowledge
    > it´s a client feature... What can be the problem ? IE versions ?
    >
    > Thanks!
    >
     
    Paulo Roberto, Aug 1, 2007
    #2
    1. Advertising

  3. Paulo Roberto wrote:
    > Hi, I have a C# ASP.net 2.0 built on VS 2005, and the piece of code:
    > javascript:confirm('are you sure delete record?') on gridview at
    > rowDataBound - OnClientClick, works fine, it asks the user and if cancels,
    > does nothing... but on my machine at HOME, even when I click cancel it
    > deletes the records... It´s a very strange problem because to my knowledge
    > it´s a client feature... What can be the problem ? IE versions ?
    >
    > Thanks!


    Don't use the javascript: protocol when you aren't putting the
    Javascript in an URL.

    The event expects a return value from the code, which is used to
    determine if the action should be canceled or not.

    So, the correct code is:

    OnClientClick="return confirm('are you sure delete record?');"

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Aug 2, 2007
    #3
  4. > So, the correct code is:
    >
    > OnClientClick="return confirm('are you sure delete record?');"
    >



    Göran, my code is the same as yours and works only on my machine at work...
    Any suggestion?
     
    Paulo Roberto, Aug 2, 2007
    #4
  5. "Paulo Roberto" <> wrote in message
    news:%23Po%...

    > What can be the problem ? IE versions ?


    Incorrect syntax is your problem...

    OnClientClick="return confirm('Are you sure you want to delete this
    record?');"


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 2, 2007
    #5
  6. Paulo Roberto wrote:
    >> So, the correct code is:
    >>
    >> OnClientClick="return confirm('are you sure delete record?');"
    >>

    >
    >
    > Göran, my code is the same as yours and works only on my machine at work...
    > Any suggestion?
    >


    Have you examined the generated code to see if there are any differences?

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Aug 2, 2007
    #6
    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. Jenet

    confirm method in javascript

    Jenet, Jul 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    414
    Kevin Spencer
    Jul 16, 2003
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    629
  3. Replies:
    0
    Views:
    566
  4. Peter Otten
    Replies:
    2
    Views:
    119
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    120
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page