Javascript:return vbscript equivalent

Discussion in 'ASP .Net' started by Jim Ciotuszynski, Jul 6, 2004.

  1. Is there an equivalent to the
    "button.attributes.add("onBlur","JavaScript:return somfunction();") ? I
    thought that vbscrpt would also do the same but when I run my code with the
    vbscript my button click event gets fired no matter if the vbscript returns
    false or true? Any help would be great.

    Thanks,
    Jim
    Jim Ciotuszynski, Jul 6, 2004
    #1
    1. Advertising

  2. See if this code helps. All you have to do is structure your client side
    script.

    <html>
    <body>
    <button OnClick="Click1()">Click Me</button>
    </body>
    <script Language="VBScript">
    Function Click1()
    IF FuncYes Then
    Msgbox "Returns True"
    Else
    Msgbox "Returns False"
    End If
    If FuncNo Then
    Msgbox "Returns True"
    Else
    Msgbox "Returns False"
    End If
    End Function
    Function FuncYes()
    FuncYes = True
    End Function
    Function FuncNo()
    FuncNo = False
    End Function

    </script>
    </html>

    Regards,

    Trevor Benedict R
    MCSD

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trevor Benedict R, Jul 6, 2004
    #2
    1. Advertising

  3. OK, this is what I have for my testing purposes:
    ASP.net project with a button and a checkbox on it. in the code behind form load I have:
    Button1.Attributes.Add("onclick", "vbscript:confirm_delete()")

    Here is the vbscript code:

    Function validMe()
    if form1.CheckBox1.Checked = False then
    validMe = False
    Else
    validMe= True
    End if
    End Function

    What I would like to happen is the button1_click event in the code behind page not to fire if the return is FALSE. I can get it to work in JavaScript just fine, I need to get it to work in Vbscript.



    Thanks,
    Jim

    "Trevor Benedict R" <> wrote in message news:%...
    > See if this code helps. All you have to do is structure your client side
    > script.
    >
    > <html>
    > <body>
    > <button OnClick="Click1()">Click Me</button>
    > </body>
    > <script Language="VBScript">
    > Function Click1()
    > IF FuncYes Then
    > Msgbox "Returns True"
    > Else
    > Msgbox "Returns False"
    > End If
    > If FuncNo Then
    > Msgbox "Returns True"
    > Else
    > Msgbox "Returns False"
    > End If
    > End Function
    > Function FuncYes()
    > FuncYes = True
    > End Function
    > Function FuncNo()
    > FuncNo = False
    > End Function
    >
    > </script>
    > </html>
    >
    > Regards,
    >
    > Trevor Benedict R
    > MCSD
    >
    > *** Sent via Devdex http://www.devdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Jim Ciotuszynski, Jul 6, 2004
    #3
  4. "Jim Ciotuszynski" <> wrote in message news:...
    OK, this is what I have for my testing purposes:
    ASP.net project with a button and a checkbox on it. in the code behind form load I have:
    Button1.Attributes.Add("onclick", "vbscript:confirm_delete()")

    Try it without the "vbscript:". I believe you only want that on the href of an anchor tag.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jul 6, 2004
    #4
  5. Tried it, the event still fires regardless of what the return value is.

    Jim
    "John Saunders" <> wrote in message news:...
    "Jim Ciotuszynski" <> wrote in message news:...
    OK, this is what I have for my testing purposes:
    ASP.net project with a button and a checkbox on it. in the code behind form load I have:
    Button1.Attributes.Add("onclick", "vbscript:confirm_delete()")

    Try it without the "vbscript:". I believe you only want that on the href of an anchor tag.
    --
    John Saunders
    johnwsaundersiii at hotmail
    Jim Ciotuszynski, Jul 6, 2004
    #5
  6. Why not write your core function in VBScript and then call it from a
    JavaScript function with the return keyword. I am sorry to put you on a
    wild goose chase. This computer that I am sitting on is a WIN98 box with
    none of my stuff to test anything for you.

    Regards

    Trevor Benedict R
    MCSD

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trevor Benedict R, Jul 6, 2004
    #6
  7. Well it looks like I'll have to bite the bullet and start writing my code in
    Javascript, it's just that I know VB very well (been using since vb for DOS.
    think I still have the software somewhere) and it's just a lot quicker for
    my development needs. Thanks for everyone's help.

    Jim Ciotuszynski
    CTO/CIO eMedsoft.com Inc.

    "Trevor Benedict R" <> wrote in message
    news:...
    > Why not write your core function in VBScript and then call it from a
    > JavaScript function with the return keyword. I am sorry to put you on a
    > wild goose chase. This computer that I am sitting on is a WIN98 box with
    > none of my stuff to test anything for you.
    >
    > Regards
    >
    > Trevor Benedict R
    > MCSD
    >
    > *** Sent via Devdex http://www.devdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Jim Ciotuszynski, Jul 6, 2004
    #7
  8. Jim Ciotuszynski

    nescafe

    Joined:
    Sep 15, 2011
    Messages:
    1
    Found this thread with no answer; you can use the statement 'window.event.returnValue = True/False' for this
    nescafe, Sep 15, 2011
    #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. sundar_s1210
    Replies:
    4
    Views:
    42,159
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    May 9, 2005
  2. Greenhorn
    Replies:
    15
    Views:
    793
    Keith Thompson
    Mar 6, 2005
  3. Replies:
    3
    Views:
    174
    Matt Kruse
    May 25, 2006
  4. divya
    Replies:
    7
    Views:
    327
    divya
    Sep 25, 2006
  5. shelleybobelly

    javascript equivalent for vbscript Date()-1

    shelleybobelly, Mar 28, 2007, in forum: Javascript
    Replies:
    18
    Views:
    269
    Dr J R Stockton
    Mar 30, 2007
Loading...

Share This Page