Click here to Skip to main content
15,907,396 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Guys,

precondition:
1. i have 2 listbox 1-that contains all items (from database) and the other one contains the selected item (blank)
2. lstAllItems.DataSource = myDataSomething;
3. lstSelectedItem -> not populated
4. i have client side control btnMove that will copy the selected item from lstAllItems listbox and copy it to the lstSelectedItem. The code responsible for this is a client side code (javascript)
5. then click save button

I have 2 error encountered during saving:
1. If EnableEventValidation is on in <%@ Page ...%> I am getting this error:
XML
Exception type: ArgumentException
    Exception 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.


2. If turned off the EnableEventValidation and when i click save button the lstSelectedItem listbox (though it was populated using javascript) but when i count the items like lstSelectedItem.Items.Count the result is zero.

Question:I read couple of articles stating to use GetPostBackEventReference method but still the issue is still there.
Posted

1 solution

Hi Jephunneh Malazarte,

You are right, you are not able to get values from list box which are added from client side (Javascript).

Solution:
just do the following steps:

  • 1. Added on hidden textbox to the page e.g. (hidtxt runat=server).
  • 2. When you click on move button then you should also set the selected value to the ListBox asn Hidden Filed with comma seperated.
  • 3. Now you should access value on server side from hidtxt instead of listbox
  • This is 100% resolve your problem.

    Thanks,
    Imdadhusen
 
Share this answer
 
Comments
Jephunneh Malazarte 22-Jul-11 4:52am    
thanks it works... :)
i was thinking that maybe there's an elegant way of doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900