Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Help With Addding Attribute to Button In Data Repeater

Reply
Thread Tools

Help With Addding Attribute to Button In Data Repeater

 
 
Sal D'Ambra
Guest
Posts: n/a
 
      01-01-2004
Hello All,

I have a data repeater control and it has a 'Delete' and 'Edit' button for
each row. I would like to add a pop-up via javascript so when a user clicks
the 'Delete' button it asks if they are sure. I know I can add an attribute
for onclick and the name of the script for a button but.... I can't figure
out how to do this for the buttons which are dynamically created. I am
looking about in the Repeater.OnItemCreated but frankly I'm stumped. Thanks
in advance for any help.

Sal
--
Sal D'Ambra
Blue Ridge Summit, PA


 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-02-2004
You need to do it in the item databound method of your repeater control :

Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
Repeater1.ItemDataBound
Dim MyDeleteButton As LinkButton
MyDeleteButton = CType(e.Item.FindControl("Linkbutton4"),
LinkButton)
MyDeleteButton.Attributes.Add("OnClick", _
"return confirm('Are you Sure you want to delete this record?');")
End Sub

"Sal D'Ambra" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello All,
>
> I have a data repeater control and it has a 'Delete' and 'Edit' button for
> each row. I would like to add a pop-up via javascript so when a user

clicks
> the 'Delete' button it asks if they are sure. I know I can add an

attribute
> for onclick and the name of the script for a button but.... I can't figure
> out how to do this for the buttons which are dynamically created. I am
> looking about in the Repeater.OnItemCreated but frankly I'm stumped.

Thanks
> in advance for any help.
>
> Sal
> --
> Sal D'Ambra
> Blue Ridge Summit, PA
>
>



 
Reply With Quote
 
 
 
 
Sal D'Ambra
Guest
Posts: n/a
 
      01-02-2004
Alessandro ,

Thank you - I have it working. You have no idea how long I spent on that.

For anyone else with this issue here is the code which which works for me:

Private Sub EducationRepeater_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
EducationRepeater.ItemDataBound

Dim MyDeleteButton As Button

If Not IsNothing(e.Item.FindControl("DeleteButton")) Then
MyDeleteButton = CType(e.Item.FindControl("DeleteButton"), Button)
MyDeleteButton.Attributes.Add("OnClick", "confirmDelete()")
End If

End Sub

Sal
--
Sal D'Ambra
Blue Ridge Summit, PA


"Alessandro Zifiglio" <(E-Mail Removed)> wrote in
message newsv3Jb.22585$(E-Mail Removed)...
> You need to do it in the item databound method of your repeater control :
>
> Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
> Repeater1.ItemDataBound
> Dim MyDeleteButton As LinkButton
> MyDeleteButton = CType(e.Item.FindControl("Linkbutton4"),
> LinkButton)
> MyDeleteButton.Attributes.Add("OnClick", _
> "return confirm('Are you Sure you want to delete this record?');")
> End Sub
>
> "Sal D'Ambra" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello All,
> >
> > I have a data repeater control and it has a 'Delete' and 'Edit' button

for
> > each row. I would like to add a pop-up via javascript so when a user

> clicks
> > the 'Delete' button it asks if they are sure. I know I can add an

> attribute
> > for onclick and the name of the script for a button but.... I can't

figure
> > out how to do this for the buttons which are dynamically created. I am
> > looking about in the Repeater.OnItemCreated but frankly I'm stumped.

> Thanks
> > in advance for any help.
> >
> > Sal
> > --
> > Sal D'Ambra
> > Blue Ridge Summit, PA
> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-02-2004
your welcome Sal
Enjoy the new year.
"Sal D'Ambra" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Alessandro ,
>
> Thank you - I have it working. You have no idea how long I spent on that.
>
> For anyone else with this issue here is the code which which works for me:
>
> Private Sub EducationRepeater_ItemDataBound(ByVal sender As Object, ByVal

e
> As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
> EducationRepeater.ItemDataBound
>
> Dim MyDeleteButton As Button
>
> If Not IsNothing(e.Item.FindControl("DeleteButton")) Then
> MyDeleteButton = CType(e.Item.FindControl("DeleteButton"), Button)
> MyDeleteButton.Attributes.Add("OnClick", "confirmDelete()")
> End If
>
> End Sub
>
> Sal
> --
> Sal D'Ambra
> Blue Ridge Summit, PA
>
>
> "Alessandro Zifiglio" <(E-Mail Removed)> wrote in
> message newsv3Jb.22585$(E-Mail Removed)...
> > You need to do it in the item databound method of your repeater control

:
> >
> > Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As
> > System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
> > Repeater1.ItemDataBound
> > Dim MyDeleteButton As LinkButton
> > MyDeleteButton = CType(e.Item.FindControl("Linkbutton4"),
> > LinkButton)
> > MyDeleteButton.Attributes.Add("OnClick", _
> > "return confirm('Are you Sure you want to delete this record?');")
> > End Sub
> >
> > "Sal D'Ambra" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hello All,
> > >
> > > I have a data repeater control and it has a 'Delete' and 'Edit' button

> for
> > > each row. I would like to add a pop-up via javascript so when a user

> > clicks
> > > the 'Delete' button it asks if they are sure. I know I can add an

> > attribute
> > > for onclick and the name of the script for a button but.... I can't

> figure
> > > out how to do this for the buttons which are dynamically created. I am
> > > looking about in the Repeater.OnItemCreated but frankly I'm stumped.

> > Thanks
> > > in advance for any help.
> > >
> > > Sal
> > > --
> > > Sal D'Ambra
> > > Blue Ridge Summit, PA
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Addding usercontrol dynmaically with postback capability news.microsoft.com ASP .Net 3 04-28-2010 06:45 PM
<DIV> addding text from code behind. Gregory ASP .Net 6 10-10-2005 05:43 AM
Using Radio button in a Data Repeater Samuel Ashley via .NET 247 ASP .Net Building Controls 1 03-31-2005 02:03 PM
Repeater Using Javascript Referencing a Column in the Repeater rwoo_98@yahoo.com ASP .Net 0 02-26-2005 05:02 PM
Repeater control with nested repeater chris.reed@digus.com ASP .Net 0 02-11-2005 05:10 PM



Advertisments