介面上如下:
<ext:Button ID="btnDel" runat="server" Icon="Delete" Text="刪除" >
<Listeners ><Click Handler="CompanyUser.DoConfirm()"/></Listeners>
</ext:Button>
還需要注意要加句這樣的代碼
<ext:ScriptManager ID="ScriptManager1" runat="server" AjaxMethodNamespace="CompanyUser">
</ext:ScriptManager>
這個的CompanyUser 就是你建立頁面的名稱如:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CompanyUser.aspx.cs" Inherits="xitong_CompanyUser" %>
CS裡面的方法如下
複製代碼 代碼如下:/// <summary>
/// 刪除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
///
[AjaxMethod]
public void onDeleteClick()
{
Coolite.Ext.Web.CheckboxSelectionModel rsm = GridPanel1.SelectionModel.Primary as Coolite.Ext.Web.CheckboxSelectionModel;
int count = 0;
foreach (Coolite.Ext.Web.SelectedRow sm in rsm.SelectedRows)
{
count = user.DeleteCompanyUser(int.Parse(sm.RecordID));
}
if (count > 0)
{
Ext.MessageBox.Alert("提示", "刪除成功").Show();
}
else
{
Ext.MessageBox.Alert("提示", "刪除失敗,沒有選中行!" ).Show();
}
BindStore();
}
/// <summary>
/// 彈出刪除對話方塊
/// </summary>
[AjaxMethod]
public void DoConfirm()
{
Ext.Msg.Confirm("訊息提示", "是否刪除選中行?", new MessageBox.ButtonsConfig
{
Yes = new MessageBox.ButtonConfig
{
Handler = "CompanyUser.onDeleteClick()",
Text = "是"
},
No = new MessageBox.ButtonConfig
{
Text = "否"
}
}).Show();
}
就OK 了