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

时间:2011-09-26 11:44:20

标签: c# javascript asp.net popup

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

<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)
    {

    }

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

3 个答案:

答案 0 :(得分:6)

您可以使用following article中显示的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>

答案 1 :(得分:0)

尝试添加

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

答案 2 :(得分:0)

onClientClick="return confirm('Are you sure you want to delete?')";