2011-10-03 153 views
1

下午好人们,我正在使用直放站,在该直放站内还有另一个直放站,每个项目都有一个按钮。当我点击这些按钮中的一个asp.net返回我以下错误:中继器进入直放站火灾事件

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

但是当我添加了Page指令EnableEventValidation =“假”我的网页,没有错误上,但不会触发我的事件。

这怎么解决?

+0

发布您的代码或您的问题将得到封闭。这是模糊的。 –

回答

1

您是否在每次回发时绑定数据?这个问题可能源于这样一个事实,发送事件的Repeater在回发后不再存在,并且每个Postback都会创建一个新的Repeater。 这就是事件验证失败的原因,您不能将事件从一个动态创建的控件引发到另一个控件。它必须是相同的控制。

简单的解决方案是只绑定页面第一次加载的数据并保持启用ViewState。

所以,在Page_Load中:

if(!IsPostBack) 
    // Bind Repeater Data here 
+0

现在我把绑定中继器为一验证,看看: 如果 { 如果(base.VehiclesResponse!= NULL){ 名单 listVehicles =基地(Page.IsPostBack!)。 VehiclesResponse; List listVehiclesOrdened = listVehicles.OrderBy(x => x.Class).ToList(); rptRatesResponse.DataSource = listVehiclesOrdened; rptRatesResponse.DataBind(); } } – mcamara

+0

现在,不返回错误,但是当我在中继器列表中插入事件不会调用事件。 我在codebehind中注册事件ItemCommand作为示例,如下所示: objRepeater.ItemCommand + = new RepeaterCommandEventHandler(objRepeater_ItemCommand); void objRepeater_ItemCommand(object source,RepeaterCommandEventArgs e) { Response.Write(“TESTE”); } – mcamara

+1

请将您网页的代码编辑为问题,这真的很难从评论中读取。 – magnattic