button control and cancel submit

Discussion in 'ASP .Net Web Controls' started by jbhopper, Jan 27, 2004.

  1. jbhopper

    jbhopper Guest

    I use Attribute.Add to call a javascript function client-side from an asp:button control. The javascript function opens a window. My problem is that the submit event fires after the javascript code executes. When I view the source in "running documents" I see that the button is declared as "type=submit", even when I provide a commandName, which I thought changed a submit button into a command button. When I try to return false from the javascript function I get "return type mismatch". I've used this method successfully in user controls, but now I can't use it in a web page. Any suggestions

    Thanks!
     
    jbhopper, Jan 27, 2004
    #1
    1. Advertising

  2. Are you putting return false in your javascript or in the click event? Try
    it this way?

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Button1.Attributes.Add("onclick", _
    "doWelcome(); return false;")
    End Sub

    If this isn't the issue, maybe you could post the code that isn't working
    and we can try again?

    Ken
    MVP [ASP.NET]

    "jbhopper" <> wrote in message
    news:...
    >I use Attribute.Add to call a javascript function client-side from an
    >asp:button control. The javascript function opens a window. My problem is
    >that the submit event fires after the javascript code executes. When I view
    >the source in "running documents" I see that the button is declared as
    >"type=submit", even when I provide a commandName, which I thought changed a
    >submit button into a command button. When I try to return false from the
    >javascript function I get "return type mismatch". I've used this method
    >successfully in user controls, but now I can't use it in a web page. Any
    >suggestions?
    >
    > Thanks!
     
    Ken Cox [Microsoft MVP], Jan 29, 2004
    #2
    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. Mark
    Replies:
    1
    Views:
    1,718
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,236
    Ghafran Abbas
    Oct 12, 2004
  3. Replies:
    2
    Views:
    6,241
  4. Paul Oakfleet
    Replies:
    1
    Views:
    858
    Chris Riesbeck
    Sep 10, 2003
  5. Indu
    Replies:
    9
    Views:
    351
Loading...

Share This Page