如何在asp.net中获得确认弹出窗口

发布于 2024-12-06 12:38:29 字数 595 浏览 0 评论 0原文

在网格内,我在网格内有一个删除按钮,并且后面有一个代码来执行删除。

<asp:TemplateField HeaderText="Edit Controls" ItemStyle-Width="15%">
 <ItemTemplate>
   <asp:LinkButton ID="Lnk_Delete" ToolTip="Delete Message" 
   CommandArgument='<%#Eval("MsgID") %>' CommandName="Delete" runat="server"> 
   <img id="Img1" src="Styles/Images/Delete.jpg" runat="server"  /></asp:LinkButton>
 </ItemTemplate>
</asp:TemplateField> 

 protected void Grid_Messagetable_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }

一切正常,如何在执行删除之前弹出确认窗口。

Inside the grid I have a delete button inside a grid and have a code behind to perform the delete.

<asp:TemplateField HeaderText="Edit Controls" ItemStyle-Width="15%">
 <ItemTemplate>
   <asp:LinkButton ID="Lnk_Delete" ToolTip="Delete Message" 
   CommandArgument='<%#Eval("MsgID") %>' CommandName="Delete" runat="server"> 
   <img id="Img1" src="Styles/Images/Delete.jpg" runat="server"  /></asp:LinkButton>
 </ItemTemplate>
</asp:TemplateField> 

 protected void Grid_Messagetable_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }

Everything works fine how to get a confirm pop up before the delete is performed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

游魂 2024-12-13 12:38:29

您可以使用 OnClientClick 属性,如以下文章中所示

<asp:LinkButton 
    ID="Lnk_Delete" 
    runat="server"
    ToolTip="Delete Message" 
    CommandArgument='<%#Eval("MsgID") %>' 
    CommandName="Delete" 
    OnClientClick="return confirm('Are you sure you want to delete this record?');"> 
    <img id="Img1" src="Styles/Images/Delete.jpg" runat="server"  />
</asp:LinkButton>

You could use the OnClientClick property as shown in the following article:

<asp:LinkButton 
    ID="Lnk_Delete" 
    runat="server"
    ToolTip="Delete Message" 
    CommandArgument='<%#Eval("MsgID") %>' 
    CommandName="Delete" 
    OnClientClick="return confirm('Are you sure you want to delete this record?');"> 
    <img id="Img1" src="Styles/Images/Delete.jpg" runat="server"  />
</asp:LinkButton>
撑一把青伞 2024-12-13 12:38:29

尝试添加

OnClientClick="return confirm('Do you want Delete?');"

Try adding

OnClientClick="return confirm('Do you want Delete?');"
☆獨立☆ 2024-12-13 12:38:29
onClientClick="return confirm('Are you sure you want to delete?')";
onClientClick="return confirm('Are you sure you want to delete?')";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文