Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Please help on Datagrid delete control button


Message #1 by anguyen@f... on Thu, 14 Feb 2002 20:11:23
I think that this is true.  If you have a server event On_Click, then you
have to use another event (like On_Mousedown, On_Mouseup, etc.) to trap
client-side

David Adams

----- Original Message -----
From: "Alvin Ling" <alvin.ling@i...>
To: "ASPX_Professional" <aspx_professional@p...>
Sent: Friday, February 15, 2002 08:43 AM
Subject: [aspx_professional] RE: Please help on Datagrid delete control bu
tton


> Aiden,
>
> My understanding is that you can't have both a client-side onclick
> (which is what you're adding) and a server-side onclick event handler...
> is this true?
>
> Alvin
>
> > -----Original Message-----
> > From: Montgomery, Aiden [mailto:Aiden.Montgomery@f...]
> > Sent: Friday, February 15, 2002 4:11 AM
> > To: ASPX_Professional
> > Subject: [aspx_professional] RE: Please help on Datagrid
> > delete control bu tton
> >
> >
> > This is a fun one that I had a great time solving.
> >
> > The following code will find your delete button and add the
> > pop-up box.
> >
> > repeater1.DataSource = newvalues;
> > repeater1.DataBind();
> >
> > try
> > {
> > Control myControl = this.FindControl("repeater1");
> >
> > foreach (Control rControl in myControl.Controls)
> > {
> >       foreach (Control riControl in rControl.Controls)
> > {
> > try
> > {
> > LinkButton myButton 
> > (LinkButton)riControl;
> > if (myButton.Text == "Delete")
> > {
> >
> > myButton.Attributes.Add("OnClick", "return confirm('Deletion
> > of documents is not reversable!\\r\\nDo you want to continue?');");
> > }
> > }
> > catch (Exception excep)
> > {
> > }
> > }
> > }
> > }
> > catch (Exception excep)
> > {
> > }
> >
> > What this does is bind the data to the repeater, this can be
> > a datagrid or datalist. It then finds the target and scrolls
> > through the controls collection. When it finds the delete
> > buttons it adds the attributes to them.
> >
> > I have it in a "try catch" so that when trying to cast the
> > control as a LinkButton the program does not fail.
> >
> > If anyone has a better or cleaner way of doing this then
> > please let me know.
> >
> > Aiden Montgomery
> > Industrial Trainee
> > Fujitsu Siemens Computers
> >
> >
> > -----Original Message-----
> > From: anguyen@f... [mailto:anguyen@f...]
> > Sent: 14 February 2002 20:11
> > To: ASPX_Professional
> > Subject: [aspx_professional] Please help on Datagrid delete
> > control button
> >
> >
> > Hello, Would any body help me on this
> >
> > I have a data grid with a Delete control.  I can click it to
> > delete the
> > record, but how can i pop up a dialog box for user to confirm
> > or cancel
> > the action.
> >
> > any help would be much appreciated
> >
> > Thanks
> >
> >
> >
> >
> >
> > $subst('Email.Unsub').
> >
> > $subst('Email.Unsub').
> >
> >
>
>
>
>
>
$subst('Email.Unsub').
>

  Return to Index