Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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
Jquery 客户端验证_Jquery_Asp.net_Validation - Fatal编程技术网

Jquery 客户端验证

Jquery 客户端验证,jquery,asp.net,validation,Jquery,Asp.net,Validation,我是asp.net编程新手 我在gridView中有以下模板字段 <asp:TemplateField HeaderText="Delete" <ItemTemplate> <asp:LinkButton runat="server" ID="lnkDelete" OnCommand="lnkDelete_Command" CommandArgu

我是asp.net编程新手

我在gridView中有以下模板字段

<asp:TemplateField
    HeaderText="Delete"
    <ItemTemplate>
        <asp:LinkButton
            runat="server"
            ID="lnkDelete"
            OnCommand="lnkDelete_Command"
            CommandArgument='<%#Eval("ItemID")%>'
            OnClientClick="showDeleteVerifiction()"
         </asp:LinkButton>
....

但是,当我单击“确定”时,该项仍然被删除。您需要添加
客户端
单击事件作为使用javascript函数。要绑定onclick javascript事件,需要使用asp.net提供的

确认功能将返回“确定”或“取消”的
true
false
。如果返回值为true,则将有回发,如果返回值为false,则不会有回发

OnClientClick="return confirm('Are you sure you want to delete');"
如果您想调用您在问题中提到的函数:

<asp:LinkButton
        runat="server"
        ID="lnkDelete"
        OnCommand="lnkDelete_Command"
        CommandArgument='<%#Eval("ItemID")%>'
        OnClientClick="return showDeleteVerifiction()"
</asp:LinkButton>

function showDeleteVerification()
{
    return confirm("Are you sure you want to delete");        
}

我认为您可以使用确认来实现您的结果:

使用
confirm

showDeleteVerification = function()
{
    confirm("not letting this pass");
    return false;
}

您是否获得了警报窗口?我使用警报(“”)尝试了该窗口,但在执行
OnClientClick=“return showdeletection()”
操作后,该窗口工作正常。我丢失了return语句
showDeleteVerification = function()
{
    confirm("not letting this pass");
    return false;
}