在我的项目中,我有一个母版页,usercontrol和使用母版页的webforms。 我的usercontrol包含文本框按钮和gridview 在我的一个页面上,当我尝试删除列确认消息框出现然后我单击确定然后该错误播出和 我需要说的是,当我在页面顶部设置EnableEventValidation =“true”时,错误没有显示,但也没有去删除事件
Microsoft JScript运行时错误:Sys.WebForms.PageRequestManagerServerErrorException:无效的回发或回调参数。使用配置或<%@ Page EnableEventValidation =“true”%>启用事件验证在一个页面中。出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件。如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证。
奇怪的是,在我使用用户控件的其他页面上没有这样的东西。 这是我的代码
那是我的gridview
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="grdKatilimci" runat="server" AutoGenerateColumns="False"
DataKeyNames="SICIL"
CellPadding="1" CellSpacing="1" BorderWidth="0"
EnableModelValidation="True" onrowdatabound="grdKatilimci_RowDataBound"
onrowcommand="grdKatilimci_RowCommand">
<Columns>
<asp:BoundField DataField="SICIL" HeaderText="Sicil No" ItemStyle-Width="55px" />
<asp:BoundField DataField="AD_SOYAD" HeaderText="Ad- Soyad" ItemStyle-Width="200px">
</asp:BoundField>
<asp:BoundField DataField="BOLUM" HeaderText="Bölüm" ItemStyle-Width="136px">
</asp:BoundField>
<asp:BoundField DataField="DEPARTMAN" HeaderText="Departman- Mağaza" ItemStyle-Width="136px">
</asp:BoundField>
<asp:BoundField DataField="GOREV" HeaderText="Pozisyon" ItemStyle-Width="136px">
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton CommandName="Sil" ImageUrl="~/Foto/del.jpg" runat="server" CommandArgument='<%# Eval("SICIL") %>' OnClientClick="return confirm('Bu kullanıcıyı silmek istediğinize emin misiniz?');" />
//the above is confirmation msg
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkKatilimciEkle" EventName="click" />
</Triggers>
</asp:UpdatePanel>
这是我的gridview的行命令事件
protected void grdKatilimci_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="Sil")
{
string sicil = e.CommandArgument.ToString();
OdbcConnection cnn = new OdbcConnection(mth.sConnection);
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = cnn;
cmd.CommandText = "DELETE FROM EDU_KATILIMCI WHERE SICIL_NO=" + sicil + " AND ID_EGITIM='" + lblId.Text + "'";
cmd.CommandType = CommandType.Text;
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
mth.FillGridView("SELECT (ADI ||' '|| IKINCI_AD ||' '|| SOYAD) AS AD_SOYAD, EP.SICIL, EP.GOREV, EP.DEPARTMAN, EP.BOLUM FROM EDU_PERSONEL EP INNER JOIN EDU_KATILIMCI EK ON EK.SICIL_NO =EP.SICIL WHERE EK.ID_EGITIM='" + lblId.Text+"' ORDER BY ADI", grdKatilimci, "");
}
}