If I add Items to a Select element at the client side and then submit the form, I get 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 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.
I do not want to disable the EventValidation. How can I register the data added at the client side to a particular element for postback validation at server side ?
I know the RegisterForEventValidation method is there, but I have never used it and even I don’t understand from the msdn.
If anyone has ever done this, can you please share a sample code with brief explanation ?
In my case, I know all the values in advance that can be added to the ListBox at the Client side, so fortunately, there is a solution for this:-