how to fix an ASP.NET 2.0 error?

Hi, I am getting the following error:

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.

Please, can some one help?
vielkacarolina1239Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vielkacarolina1239Author Commented:

I understand why I am getting this error. The reason is that I have a web user control that contains 4 dropdown menus. I loop through all 4 drop down menus and set some data into the drop down menus controls in the ascx.cs file.

                DropDownList[] dropDownListArr = new DropDownList[12];
                dropDownListArr[0] = DropDownList0;
                dropDownListArr[1] = DropDownList1;
                dropDownListArr[2] = DropDownList2;
                dropDownListArr[3] = DropDownList3;

                for (int i = 0; i < 4; i++)
                {
                     dropDownListLabelArr[i].Text = "text" + i.ToString();
                }

I know that if I use the following code in the web config, the problem will go away
    <pages enableEventValidation="false" />

However, I don't whant to use the above line of code. Is there another way to solf this problem?
0
vielkacarolina1239Author Commented:
The looping of the dropdown menus is been done in the Page_Load event of the ascx.cs file
0
vielkacarolina1239Author Commented:
I also found that I need to implement IPostBackDataHandler interface for the control that is been changed in the Page_Load event. This will register the changes in the dropdown menus and update the ViewState for this control accordantly when I pass the dropdown menu to the following method.
RegisterRequiresPostBack(myDropDownMeny)

Please, can some one show me how to implement IPostBackDataHandler interface for a drop down menu so that I can use RegisterRequiresPostBackt() and this will update the ViewState when there is a changed in a drop down menu?
0
NazoUKCommented:
When you say dropdown menu, do you just mean a standard dropdownlist control?
If you are adding items programatically in your code behind you shouldn't need to register anything, the items will be automatically added to the viewstate. Are you making any client side changes with javascript?
Also, if it is a dropdownlist you'll want to modify its contents using the items collection, eg. Dropdownlist1.items.add("Text") or Dropdownlist1.items[0].text = "Text" something like that.

Sorry if I've got the wrong end of the stick.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.