Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C命令行链接按钮添加Javascript_C#_Visual Web Developer - Fatal编程技术网

C# C命令行链接按钮添加Javascript

C# C命令行链接按钮添加Javascript,c#,visual-web-developer,C#,Visual Web Developer,我使用下面的C替换GridView上命令行中的文本“编辑、删除和选择” 我想通过使用javascript“确认”对话框来改进这一点,让用户在删除行之前进行双重检查。如何从LinkButton对象执行此操作 private void commandIcons(GridViewRow row) { if (row.Cells[0].Controls.Count == 5) { // we have a edit delete select control row ty

我使用下面的C替换GridView上命令行中的文本“编辑、删除和选择”

我想通过使用javascript“确认”对话框来改进这一点,让用户在删除行之前进行双重检查。如何从LinkButton对象执行此操作

private void commandIcons(GridViewRow row)
{
    if (row.Cells[0].Controls.Count == 5)
    {
        // we have a edit delete select control row type, replace text labels with icons
        LinkButton lbedit = (LinkButton)row.Cells[0].Controls[0];
        lbedit.Text = lbedit.Text == "Edit" ? "<img title=\"Edit\" class=\"icon\" src=\"Images/database_edit.png\" />" : lbedit.Text;

        LinkButton lbdelete = (LinkButton)row.Cells[0].Controls[2];
        lbdelete.Text = lbdelete.Text == "Delete" ? "<img title=\"Delete\" class=\"icon\" src=\"Images/delete.png\" />" : lbdelete.Text;

        LinkButton lbselect = (LinkButton)row.Cells[0].Controls[4];
        lbselect.Text = lbselect.Text == "Select" ? "<img title=\"Select\" class=\"icon\" src=\"Images/accept.png\" />" : lbselect.Text;
    }
}

您可以将OnClientClick添加到linkbutton以请求确认。然后使用OnClick执行C函数。希望能有帮助

<asp:LinkButton ID="Deletebutton" runat="server" CausesValidation="False" OnClientClick='return confirm("Are you sure you want to remove this?");'  OnClick="DeleteBrand">

很好,OnClientClick正是我想要的财产!很高兴听到,我自己在所有的aspx页面中都使用了它。很高兴我能帮忙