running client side script after an <asp:ButtonColumn> click event

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Re: running client side script after an <asp:ButtonColumn> click event

    "z. f." wrote
    > i have a datagrid with a delete button for each row in the grid.
    > when the delete button is clicked i need to ask the user in a "confirm"
    > message box if he's sure he wants to delete.
    Get a reference to the delete button in the ItemCreated event of your
    datagrid, then use:

    btnDelete.Attributes.Add("onclick", "return confirm('Delete record?');");

    Steven

    - - -



    Steven Spits Guest

  2. Similar Questions and Discussions

    1. client side event for grid
      This is probably a simple one, but I cannot seem to find an example. I have a datagrid with each row containing Checkbox | Textbox |...
    2. client side checkbox event
      This is probably a simple one, but I cannot seem to find an example. I have a datagrid with each row containing Checkbox | Textbox |...
    3. Client Side Script interferes with Server Side Script?
      I added the form validation script (Java Script) to the head section of my insert records form page which works great when tested but when I submit...
    4. Server-side event for row click?
      Hi, is it possible to get a server-side event when the user clicks on a datagrid row? The user shouldn't be forced to click on a certain column...
    5. Sending Client Side Event ?
      "Genival" <geniobr@hotmail.com> wrote in message news:e1x0bIOdDHA.2804@TK2MSFTNGP11.phx.gbl... You can't quite do this. The only thing your...
  3. #2

    Default Re: running client side script after an <asp:ButtonColumn> click event

    "z. f." wrote:
    > how would you get a reference to the buttoncolumn since it does not have
    an
    > ID attribute
    >
    > <asp:ButtonColumn Text="del" ButtonType="PushButton"
    > CommandName="Delete"></asp:ButtonColumn>
    >
    > and also the findControl method would not cast to the boundColumn type of
    > the button - the following line of code will not compile:
    > Dim btn As System.Web.UI.WebControls.ButtonColumn =
    > CType(e.Item.FindControl("btnDelIDIDID"), ButtonColumn)
    Dim btnDelete As Button = CType(e.Item.Cells(0).Controls(0), Button)

    Modify the indexes!

    Steven

    - - -


    Steven Spits Guest

  4. #3

    Default running client side script after an <asp:ButtonColumn> click event

    Hi,

    i have a datagrid with a delete button for each row in the grid.
    when the delete button is clicked i need to ask the user in a "confirm"
    message box if he's sure he wants to delete.
    the problem is that the
    <asp:ButtonColumn ButtonType="PushButton" CommandName="Delete" .... don't
    have a property to allow onclick to run client side script . how can this
    be,

    an i missing here something, cause there must be a way to do this without
    implementing the button on my own!

    TIA, z.


    z. f. Guest

  5. #4

    Default Re: running client side script after an <asp:ButtonColumn> click event

    "z. f." wrote:
    > but somewhere i get the feeling that getting
    > to the button using it's index (that might change
    > tomorrow) and having to take care of this index in
    > order that when it changed the code will not fail is
    > not the state of the art programming practice,
    Use a foreach to loop all cells and all controls in each cell to search for
    your button. You could use the CommandName or CommandArgument as a
    search-criteria.

    Steven

    - - -


    Steven Spits Guest

  6. #5

    Default Re: running client side script after an <asp:ButtonColumn> click event

    "Steven Spits" wrote:
    > Use a foreach to loop all cells and all controls in each cell to search
    > for your button. You could use the CommandName or
    > CommandArgument as a search-criteria.
    *or* you could also use a TemplateColumn and put a normal button in it,
    which can be given an ID. That way, you could use FindControl().

    Steven

    - - -


    Steven Spits Guest

  7. #6

    Default Re: running client side script after an <asp:ButtonColumn> click event

    how would you get a reference to the buttoncolumn since it does not have an
    ID attribute

    <asp:ButtonColumn Text="del" ButtonType="PushButton"
    CommandName="Delete"></asp:ButtonColumn>

    and also the findControl method would not cast to the boundColumn type of
    the button - the following line of code will not compile:
    Dim btn As System.Web.UI.WebControls.ButtonColumn =
    CType(e.Item.FindControl("btnDelIDIDID"), ButtonColumn)

    TIA,





    "Steven Spits" <steven.spits@servico.be.net> wrote in message
    news:um9C4iFWEHA.3740@TK2MSFTNGP12.phx.gbl...
    > "z. f." wrote
    >
    > > i have a datagrid with a delete button for each row in the grid.
    > > when the delete button is clicked i need to ask the user in a "confirm"
    > > message box if he's sure he wants to delete.
    >
    > Get a reference to the delete button in the ItemCreated event of your
    > datagrid, then use:
    >
    > btnDelete.Attributes.Add("onclick", "return confirm('Delete record?');");
    >
    > Steven
    >
    > - - -
    >
    >
    >

    z. f. Guest

  8. #7

    Default Re: running client side script after an <asp:ButtonColumn> click event

    the way i did got a reference to the button is:
    Dim btn As System.Web.UI.WebControls.Button = e.Item.Cells(4).Controls(0)

    btn.Attributes.Add("onclick", "return confirm('Delete record?');")

    btn.CausesValidation = False (this doesn't work - how can i do this is another question.)



    but somewhere i get the feeling that getting to the button using it's index (that might change tomorrow) and having to take care of this index in order that when it changed the code will not fail is not the state of the art programming practice, i wish someone in this newsgroup will state the microsoft engineers opinion regarding us having to program this way!





    "z. f." <zigi@info-scopeREMSPAM.co.il> wrote in message news:%23Id0TpFWEHA.3368@TK2MSFTNGP10.phx.gbl...
    > how would you get a reference to the buttoncolumn since it does not have an
    > ID attribute
    >
    > <asp:ButtonColumn Text="del" ButtonType="PushButton"
    > CommandName="Delete"></asp:ButtonColumn>
    >
    > and also the findControl method would not cast to the boundColumn type of
    > the button - the following line of code will not compile:
    > Dim btn As System.Web.UI.WebControls.ButtonColumn =
    > CType(e.Item.FindControl("btnDelIDIDID"), ButtonColumn)
    >
    > TIA,
    >
    >
    >
    >
    >
    > "Steven Spits" <steven.spits@servico.be.net> wrote in message
    > news:um9C4iFWEHA.3740@TK2MSFTNGP12.phx.gbl...
    > > "z. f." wrote
    > >
    > > > i have a datagrid with a delete button for each row in the grid.
    > > > when the delete button is clicked i need to ask the user in a "confirm"
    > > > message box if he's sure he wants to delete.
    > >
    > > Get a reference to the delete button in the ItemCreated event of your
    > > datagrid, then use:
    > >
    > > btnDelete.Attributes.Add("onclick", "return confirm('Delete record?');");
    > >
    > > Steven
    > >
    > > - - -
    > >
    > >
    > >
    >
    >
    z. f. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139