【问题标题】:how to add a tooltip and confirm message box to asp CommandField(image button)如何向asp CommandField(图像按钮)添加工具提示并确认消息框
【发布时间】:2013-08-09 03:00:36
【问题描述】:
     <asp:GridView ID="GridView1" runat="server" 
                        AllowPaging="True" AllowSorting="True"
                        DataMember="DefaultView" 
                        DataSourceID="SqlDataSource1"...
     >
     <RowStyle BackColor="#EFF3FB" />
                        <Columns>
                            <asp:BoundField ...

                            <asp:CommandField  ButtonType="Image" DeleteText="Delete" ShowDeleteButton="True" DeleteImageUrl="images/deletered1.png"></asp:CommandField>                               
                        </Columns>                    
                        <FooterStyle BackColor="#507CD1" .../>
                    </asp:GridView>

我有一个网格视图,每行都有一个 &lt;asp:CommandField&gt;,但我找不到设置工具提示文本(“删除”)或确认消息框(类似于“你确定吗?”之类的)

【问题讨论】:

    标签: asp.net gridview tooltip commandfield


    【解决方案1】:

    尝试将您的CommandField 转换为TemplateField,如下所示:

    <asp:TemplateField HeaderText="Delete">
        <ItemTemplate>
            <asp:Button ID="deleteButton" runat="server" CommandName="Delete" Text="Delete"
                OnClientClick="return confirm('Are you sure you want to delete this user?');" />
    </ItemTemplate>
    </asp:TemplateField>
    

    那么你只需要在代码隐藏中处理你的Command

    【讨论】:

    • 谢谢,我想我应该使用 而不是
    猜你喜欢
    • 2020-10-03
    • 1970-01-01
    • 2017-02-28
    • 2013-08-17
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多