Discussion:
gridview javascript confirmation popup
Smotritsky, Alex
2007-08-20 14:36:33 UTC
Permalink
In a gridview I'd like to pop up a javascript confirmation dialog to
allow the user to confirm that they want a server side action taken
after they click on a control in the gridview like a button or
linkbutton. Anyone know how to do this?






===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Ryan Heath
2007-08-20 14:45:50 UTC
Permalink
Hi,

Try adding onclick='return confirm("Are you really sure?");' to the
(link)button.

HTH
// Ryan
Post by Smotritsky, Alex
In a gridview I'd like to pop up a javascript confirmation dialog to
allow the user to confirm that they want a server side action taken
after they click on a control in the gridview like a button or
linkbutton. Anyone know how to do this?
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Potter, Mark
2007-08-20 14:49:16 UTC
Permalink
<asp:TemplateField HeaderText="Select">

<ItemTemplate>

<asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("CategoryID")
%>' CommandName="Delete" runat="server">Delete</asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>


protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)

{

LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");

l.Attributes.Add("onclick", "javascript:return " +

"confirm('Are you sure you want to delete this record " +

DataBinder.Eval(e.Row.DataItem, "CategoryID") + "')");

}

}

http://www.gridviewguy.com/ArticleDetails.aspx?articleID=138


-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Smotritsky, Alex
Sent: Monday, August 20, 2007 10:37 AM
To: DOTNET-***@DISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] gridview javascript confirmation popup

In a gridview I'd like to pop up a javascript confirmation dialog to
allow the user to confirm that they want a server side action taken
after they click on a control in the gridview like a button or
linkbutton. Anyone know how to do this?






===================================
This list is hosted by DevelopMentor(r) http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...