Within the temlpate of the repeater, I have multiple panels which have their visible property set according to some logic based on a databound value.
Withni each of these panels, I have the following asp:buttons:
<asp:Button Text="Add to basket" CommandArgument='<%#Container.DataItem("id") %>' CommandName="Add_To_Basket" runat="server" />
The sub below is a bit garbled - how do I need to rewrite it to get the ID value into the redirect string?
Sub Button_Click(ByVal s As Object, ByVal e As RepeaterCommandEventArgs) Dim strRedirect As String If e.CommandName = "Add_To_Basket" Then strRedirect = "test.aspx?id=" & e.Item.Controls( 1).CommandArgument Response.Redirect(strRedirect) End If End Sub
Sub Button_Click(ByVal s As Object, ByVal e As RepeaterCommandEventArgs)
Dim strRedirect As String
If e.CommandName = "Add_To_Basket" Then
strRedirect = "test.aspx?id=" & e.CommandArgument.ToString()
Response.Redirect(strRedirect)
End If
End Sub
but got the following error message:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> 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.
Basically, if you are reloading the repeater in a page event that fires prior to the Repeater's OnItemCommand event, the viewstate is wiped out and the button's ID does not match in the event validation.
Not the solution you were looking for?
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.
Premium Content
You need an Expert Office subscription to comment.Start Free Trial