开发者

Fire Event With Repeater into Repeater

开发者 https://www.devze.com 2023-04-11 00:10 出处:网络
Good Afternoon People, I\'m using a Repeater, and within that repeater there is another repeater, there is a button for each item. When I click on one of these buttons asp.net returns me the following

Good Afternoon People, I'm using a Repeater, and within that repeater there is another repeater, there is a button for each item. When I click on one of these buttons asp.net returns me the following error:

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature开发者_如何学Go 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.

But when I add the Page directive EnableEventValidation = "false" on my page, no error but does not fire my event.

How can this be resolved?


Do you bind the data at each postback? The problem probably originates from the fact, that the Repeater that sent the event is not there anymore after the postback, and a new Repeater is created every Postback. That's why the event validation fails, you cannot fire events from one dynamically created control to another one. It has to be the same control.

The easy solution would be to only bind the data on the first load of the Page and keep ViewState enabled.

So, in Page_Load:

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

精彩评论

暂无评论...
验证码 换一张
取 消