views:

667

answers:

1

I have a repeater that contains a few items and among them there are a DropDownList and a Button.

The goal here is to associate an item from the DDL with the selected repeater row.

ASPX Code:

<asp:Repeater ID="sharedPlansList" runat="server"
    onitemdatabound="sharedPlansList_ItemDataBound"
    onitemcommand="sharedPlansList_ItemCommand">
    <ItemTemplate>
        <div>
            <h1>&middot; <%# Eval("ProductName") %></h1>
            <div>
            Associer le domaine : 
            <asp:DropDownList runat="server" ID="domainList" />
            <asp:Button ID="associateDomaine" Text="Associer" runat="server"
                CommandArgument='<%# Container.DataItem %>' />
            </div>
            <div>
                Domaines : 
                <asp:BulletedList runat="server" ID="sharedPlanDomains" />
            </div>
        </div>
    </ItemTemplate>
</asp:Repeater>

The problem:

When I click the button I have each time an Invalid Postback or Callback exception ( 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. ). But everything seems really standard without anything really exotic. I do not add anything or controls by javascript either.

I have seen solutions where you could put <pages enableEventValidation="false" /> in the web.config but I am not sure it's a good solution since I want to make sure to keep the asp.net built-in security model.

Does any work-around exist?

A: 

I can't be certain without testing your code a bit (which I don't have time to do right this second), but can you verify if the dynamic CommandArgument you are assigning to your button is the culprit? If you take it out, does the error keep getting thrown?

If that's the case, you could try to handle each row in the OnItemDataBound handler and call

ClientScript.RegisterForEventValidation("associateDomaine", -->CommandArgHere<--);
womp
It's not linked since the error is since before CommandArgument has been added :/
Erick