从Telerik确认警报

时间:2015-08-01 11:18:12

标签: telerik

我想在从Telerik网格删除记录之前使用Telerik确认警报。 Telerik警报正在显示,但是当我选择OK时,则没有任何事情发生。

  <telerik:GridTemplateColumn  UniqueName="TemplateEditColumn"AllowFiltering="False" AllowSorting="True" HeaderText="Action" HeaderStyle-HorizontalAlign="Center"  ItemStyle-HorizontalAlign="Center" >
    <ItemTemplate>
         <div class="">
    <asp:ImageButton ID="EditLink"  runat="server"CausesValidation="False" 
      ImageUrl="~/images/edit.png" AlternateText="Edit" ToolTip="Edit" />
    <asp:ImageButton ID="btnDelete" runat="server" CausesValidation="False" CommandName="Delete" 
     CommandArgument='<%#Eval("AutoID") %>'
     ImageUrl="~/images/Delete.png" AlternateText="Delete" ToolTip="Delete" 
    OnClientClick="radconfirm('Are you sure?', confirmCallBackFn);" />
        </div>
        </ItemTemplate>
    </telerik:GridTemplateColumn>

这里是JS函数

            function confirmCallBackFn(arg) {
              return false;

          }

CodeBehind

 protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    try
    {
        if (e.CommandName == "Delete")
        {
            Int32 id = Convert.ToInt32(e.CommandArgument);
             //Delete Logic
            lblMessage2.Text = "User has been deleted Successfully.";
            Page.ClientScript.RegisterStartupScript(
            GetType(),
            "MyKey",
            "refreshGrid();",
            true);


        }


    }
    catch (Exception ex)
    {

        AppConfig.Log(ex.Message);  
    }

}

1 个答案:

答案 0 :(得分:0)

为什么使用GridTemplateColumn?您可以使用GridDeleteCommandColumnGridButtonCommandColumn,以便默认情况下会有ConfirmTextFormatString。所以需要javascript函数来处理这个问题。

尝试以下代码:

<telerik:GridButtonColumn ButtonType="ImageButton" 
CommandName="Delete" ConfirmTextFormatString="Are you sure to Delete?"  
ConfirmDialogType="classic" HeaderText="Delete" 
UniqueName="DeleteColumn"> </telerik:GridButtonColumn>

只需更改上面的列类型即可。它将在确定按下后删除数据。