此問題開始我也糾結了很久,按照錯誤提示是把
EnableEventValidation屬性設爲true就OK ,但是設置之後發現,事件都不觸發了,所以無濟於事。
在PageLoad事件中綁定數據
protected void Page_Load(object sender, EventArgs e)
{
Repeater1.DataSource = depart.ReturnAll();
Repeater1.DataBind();
}
這是Repeater事件的代碼,點擊刪除按鈕後實現刪除功能
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
if (depart.DelDepartByID(e.CommandArgument.ToString()))
{
UIHelper.ShowMsgBox("刪除成功!", Page, this.GetType());
}
}
}
當點擊刪除的時候就出現這個問題:
回發或回調參數無效。在配置中使用 <pages enableEventValidation="true"/> 或在頁面中使用 <%@ Page EnableEventValidation="true" %> 啓用了事件驗證。出於安全目的,此功能驗證回發或回調事件的參數是否來源於最初呈現這些事件的服務器控件。如果數據有效並且是預期的,則使用 ClientScriptManager.RegisterForEventValidation 方法來註冊回發或回調數據以進行驗證。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = depart.ReturnAll();
Repeater1.DataBind();
}
}