alivemedia
asked on
delete confirm popup on asp hyperlink inside repeater control?
I want to add a confirm delete javascript to my delete hyperlink's inside a repeater control, anyone have any ideas?
Here's my aspx code:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSourc e1">
<ItemTemplate>
<div style="float:left; padding:10px; text-align:center;">
<asp:HyperLink ID="ImageLink" runat="server" ImageUrl='<%# DataBinder.Eval(Container. DataItem, "ImageId","~/propertyimage s/{0}-sm.j pg") %>' NavigateUrl='#' /><br />
<asp:HyperLink ID="DeleteLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container. DataItem, "ImageId","ViewProperty.as px?Propert yId="+Requ est.QueryS tring("Pro pertyId")+ "&ImageId= {0}") %>' >Delete</asp:HyperLink>
</div>
</ItemTemplate>
</asp:Repeater>
Here's my aspx code:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSourc
<ItemTemplate>
<div style="float:left; padding:10px; text-align:center;">
<asp:HyperLink ID="ImageLink" runat="server" ImageUrl='<%# DataBinder.Eval(Container.
<asp:HyperLink ID="DeleteLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.
</div>
</ItemTemplate>
</asp:Repeater>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or you could do it this way...even simpler ;)
<span onclick="return confirm('Do you really want to delete this record?');"> <asp:HyperLink ID="DeleteLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container. DataItem, "ImageId","ViewProperty.as px?Propert yId="+Requ est.QueryS tring("Pro pertyId")+ "&ImageId= {0}") %>' >Delete</asp:HyperLink></s pan>
<span onclick="return confirm('Do you really want to delete this record?');"> <asp:HyperLink ID="DeleteLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.
Sorry ..I didnt see Jason's post....My apologies
rajesh75,
That was my #1 proposal (of the 2 for .NET 1.1).... :-)
-- Jason
That was my #1 proposal (of the 2 for .NET 1.1).... :-)
-- Jason
In the accepted solution, accepted for .net 2.0 is :
<asp:HyperLink OnClientClick="return confirm('Are you sure?');" ID="DeleteLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container. DataItem, "ImageId","ViewProperty.as px?Propert yId="+Requ est.QueryS tring("Pro pertyId")+ "&ImageId= {0}") %>' >Delete</asp:HyperLink>
But using NavigateUrl means it redirects to specified URL. To use Postback feature of dot net, its better to use :
<asp:LinkButton ID="LinkButton1" CommandName="Fold" OnClientClick="return confirm('Are you sure?');" CommandArgument='<%# Eval("Folder_Id") %>' runat="server">LinkButton< /asp:LinkB utton>
and in Rpt_ITemcommand event :
if (e.CommandName == "Fold")
{
string foldid = e.CommandArgument.ToString ();
..
is better one.
<asp:HyperLink OnClientClick="return confirm('Are you sure?');" ID="DeleteLink" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.
But using NavigateUrl means it redirects to specified URL. To use Postback feature of dot net, its better to use :
<asp:LinkButton ID="LinkButton1" CommandName="Fold" OnClientClick="return confirm('Are you sure?');" CommandArgument='<%# Eval("Folder_Id") %>' runat="server">LinkButton<
and in Rpt_ITemcommand event :
if (e.CommandName == "Fold")
{
string foldid = e.CommandArgument.ToString
..
is better one.
ASKER