473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Confirm Delete popup from a LinkButton in a repeater

I have a repeater which shows Group names.

(Skip this part if you want rather irrelevant)
The groups are ordered and formatted:
Parent
---Child
------Grand Child

(okay start reading again please)

The code (html side) looks like this:

<table id="Table1">

<asp:Repeater id="rptGroups" runat="server"
OnItemCommand="Button_ItemCommand">

<HeaderTemplate>

</HeaderTemplate>

<ItemTemplate>

<tr>

<td>

<img width='<%# Int32.parse(DataBinder.Eval(Container.DataItem,
"lvl") * 20) %>' height="1" />

<asp:Label Runat="server" CssClass="FormFieldLabel">

<%# DataBinder.Eval(Container.DataItem, "GroupName") %>

</asp:Label>

</td>

<td>

<asp:LinkButton CommandName="ID"
Text='<%#DataBinder.GetPropertyValue(me, "SelectUserButtonName")%>'
CommandArgument='<%#DataBinder.Eval(Container.Data Item, "GrpID")%>'
runat="server" ID="Linkbutton1" CssClass="FormLnkBtn" />

</td>

</tr>

</ItemTemplate>

<FooterTemplate>

</FooterTemplate>

</asp:Repeater>

</table>


the link button line:
<asp:LinkButton CommandName="ID"
Text='<%#DataBinder.GetPropertyValue(me, "SelectUserButtonName")%>'
CommandArgument='<%#DataBinder.Eval(Container.Data Item, "GrpID")%>'
runat="server" ID="Linkbutton1" CssClass="FormLnkBtn" />


Creates a link button, sets the text = the value of
"SelectUserButtonName" property of the parent page (this phrase is
dynamically changed depending on the language of the user).

It adds a CommandArgument which happens to be the key field value for
that group. Currently when a user clicks the button the code collects
the value from the CommandArguement to know which row to work with.

Sub Button_ItemCommand(ByVal Sender As Object, _

ByVal e As RepeaterCommandEventArgs)

If e.CommandName = "ID" Then

'PopUp(e.CommandArgument.ToString() + " " + hdnFor.Value)

RaiseEvent UserSelected(e.CommandArgument.ToString)

End If

End Sub

I want to dynamically add code to confirm a delete.

I have done this before with regular buttons and link buttons however,
as this one seems to be dynamically added I can't refer to it by ID
because I get an error saying it doesn't exist.

Here is how the HTML renders right now:

<a id="ShowGroupMembership1_rptGroups__ctl6_Linkbutto n1"
class="FormLnkBtn" href="javascript:{if (typeof(Page_ClientValidate)
!= 'function' || Page_ClientValidate())
__doPostBack('ShowGroupMembership1$rptGroups$_ctl6 $Linkbutton1','')}
">Delete</a>


as you can see the id is NOT LinkButton1 anymore, so of course I
cannot find it.

Just to make things a bit more difficult, this is a control and
depending on parameters set it can either delete the group OR simply
Raise and event to the parent sending the key field value of the
selected group.

I am currently trying to get the confirm delete to work.

Thanks for your time!

I did find this c# link, but I work in VB and have not been able to
'translate' it.

http://davidhayden.com/blog/dave/arc...03/16/178.aspx
Nov 18 '05 #1
1 5209
Hi Sandy,

You can try to wrap your linkbutton with a <span> element that contains a java script confirmation message. For example:

<span onclick="return confirm('do you really want to delete this item?')">
<asp:LinkButton CommandName="ID"
Text='<%#DataBinder.GetPropertyValue(me, "SelectUserButtonName")%>'
CommandArgument='<%#DataBinder.Eval(Container.Data Item, "GrpID")%>'
runat="server" ID="Linkbutton1" CssClass="FormLnkBtn" />
</span>

You can customize the confirmation message by using <%=%> or <%#%> fragments.

Regards,

Mauricio
Sieena Software

"Sandy" wrote:
I have a repeater which shows Group names.

(Skip this part if you want rather irrelevant)
The groups are ordered and formatted:
Parent
---Child
------Grand Child

(okay start reading again please)

The code (html side) looks like this:

<table id="Table1">

<asp:Repeater id="rptGroups" runat="server"
OnItemCommand="Button_ItemCommand">

<HeaderTemplate>

</HeaderTemplate>

<ItemTemplate>

<tr>

<td>

<img width='<%# Int32.parse(DataBinder.Eval(Container.DataItem,
"lvl") * 20) %>' height="1" />

<asp:Label Runat="server" CssClass="FormFieldLabel">

<%# DataBinder.Eval(Container.DataItem, "GroupName") %>

</asp:Label>

</td>

<td>

<asp:LinkButton CommandName="ID"
Text='<%#DataBinder.GetPropertyValue(me, "SelectUserButtonName")%>'
CommandArgument='<%#DataBinder.Eval(Container.Data Item, "GrpID")%>'
runat="server" ID="Linkbutton1" CssClass="FormLnkBtn" />

</td>

</tr>

</ItemTemplate>

<FooterTemplate>

</FooterTemplate>

</asp:Repeater>

</table>


the link button line:
<asp:LinkButton CommandName="ID"
Text='<%#DataBinder.GetPropertyValue(me, "SelectUserButtonName")%>'
CommandArgument='<%#DataBinder.Eval(Container.Data Item, "GrpID")%>'
runat="server" ID="Linkbutton1" CssClass="FormLnkBtn" />


Creates a link button, sets the text = the value of
"SelectUserButtonName" property of the parent page (this phrase is
dynamically changed depending on the language of the user).

It adds a CommandArgument which happens to be the key field value for
that group. Currently when a user clicks the button the code collects
the value from the CommandArguement to know which row to work with.

Sub Button_ItemCommand(ByVal Sender As Object, _

ByVal e As RepeaterCommandEventArgs)

If e.CommandName = "ID" Then

'PopUp(e.CommandArgument.ToString() + " " + hdnFor.Value)

RaiseEvent UserSelected(e.CommandArgument.ToString)

End If

End Sub

I want to dynamically add code to confirm a delete.

I have done this before with regular buttons and link buttons however,
as this one seems to be dynamically added I can't refer to it by ID
because I get an error saying it doesn't exist.

Here is how the HTML renders right now:

<a id="ShowGroupMembership1_rptGroups__ctl6_Linkbutto n1"
class="FormLnkBtn" href="javascript:{if (typeof(Page_ClientValidate)
!= 'function' || Page_ClientValidate())
__doPostBack('ShowGroupMembership1$rptGroups$_ctl6 $Linkbutton1','')}
">Delete</a>


as you can see the id is NOT LinkButton1 anymore, so of course I
cannot find it.

Just to make things a bit more difficult, this is a control and
depending on parameters set it can either delete the group OR simply
Raise and event to the parent sending the key field value of the
selected group.

I am currently trying to get the confirm delete to work.

Thanks for your time!

I did find this c# link, but I work in VB and have not been able to
'translate' it.

http://davidhayden.com/blog/dave/arc...03/16/178.aspx

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joe Finsterwald | last post by:
Recently I needed to add a confirm to a LinkButton that called a JavaScript function on success, and did nothing on failure. I found documentation on adding a confirm, but not on how to place a...
4
by: Calvin Lai | last post by:
Hi all, Does anyone know how I could add a confirm (client side) feature on those Delete Linkbutton in DataGrid? Thanks,
2
by: mark | last post by:
im having issues in creating a javascript confirm option on pressing a delete button in a datagrid - ive tried a few things but nothing seems to work (either crashes or does nothing) my codebehind...
3
by: Arne | last post by:
I have a delete column in a datagird. I would like to execute cmdDelete.Attributes.Add("onclick", "return confirm('Delete this record?');") somewhere. Where is the right place to put this code?
0
by: azbehzad | last post by:
Dear Guys, I have a problem with putting delete confirm in my code I add this code in Gridview_RowDataBound() event protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)...
14
by: darrel | last post by:
Is it possible to pre-empt the javascript function used to do a postback from a linkbutton? I'd like to use linkbutton to delete a record and want to add a confirmation box via javascript "are...
2
by: dddan | last post by:
Here's my code: <asp:LinkButton OnClick="DeleteFile" OnClientClick="if (!confirm ('Are you certain you want to delete this file?') ) return false;" runat="server" ID="DeleteButton">DELETE...
5
by: Peter Larsen [CPH] | last post by:
Hi, The following sample shows a LinkButton in the HeaderTemplate of a Repeater control. The problem is that i'm not able to access the linkbutton in code (in the cs file) as long as the...
2
by: RN1 | last post by:
I have a DataList which displays the first & last name of users as links (LinkButtons). When the links are clicked, 2 textboxes appear - one with the first name & the other with the last name - for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.