change button type from "submit" to "button"

Discussion in 'ASP .Net' started by Tony WONG, Apr 22, 2010.

  1. Tony WONG

    Tony WONG Guest

    the button is created at runtime

    the button is used as "select all checkbox" in gridview by javascript

    Dim lc As New Button
    lc.Text = "Select All"
    lc.Attributes.Add("onclick", "SelectAll('" & GridViewID & "');")
    container.Controls.Add(lc)

    when the button is clicked, it run javascript "but then submit".

    how can i change the button type from "submit" to "button"

    so that it can only run the javascript.

    Thanks.

    tony
     
    Tony WONG, Apr 22, 2010
    #1
    1. Advertisements

  2. On Apr 22, 6:22 am, "Tony WONG" <> wrote:
    > the button is created at runtime
    >
    > the button is used as "select all checkbox" in gridview by javascript
    >
    >     Dim lc As New Button
    >     lc.Text = "Select All"
    >     lc.Attributes.Add("onclick", "SelectAll('" & GridViewID & "');")
    >     container.Controls.Add(lc)
    >
    > when the button is clicked, it run javascript "but then submit".
    >
    > how can i change the button type from "submit" to "button"
    >
    > so that it can only run the javascript.
    >
    > Thanks.
    >
    > tony


    lc.Attributes.Add("onclick", "SelectAll('" & GridViewID & "');return
    false;")
     
    Alexey Smirnov, Apr 22, 2010
    #2
    1. Advertisements

  3. Tony WONG

    Tony WONG Guest

    Thanks a lot.
     
    Tony WONG, Apr 22, 2010
    #3
    1. Advertisements

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,982
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,559
    Ghafran Abbas
    Oct 12, 2004
  3. Replies:
    2
    Views:
    6,653
  4. Network-Man
    Replies:
    5
    Views:
    83,802
    gaul1
    Jul 7, 2012
  5. Sam
    Replies:
    1
    Views:
    1,811
    Brian Kenneth Nielsen
    Nov 25, 2008
  6. Guest
    Replies:
    2
    Views:
    1,865
    Guest
    Oct 25, 2004
  7. Replies:
    4
    Views:
    1,447
    Adrienne Boswell
    Mar 23, 2010
  8. babygodzilla
    Replies:
    4
    Views:
    264
    babygodzilla
    Sep 18, 2007
Loading...