postback event error

W

Wendi Taranto

I have a dropDownList on a web page that is populated by client-side script.
I get an error on PostBack of the page. I've seen quite a few posts about
this, so I understand the issue, and why it's occurring. I added
EnableEventValidation="false" to my @Page directive, and now i can submit
the form with the client-side populated listbox. In my Protected Sub
btnSave_Click event, when I iterate the listbox that was populated
client-side, I cannot see any items in the list. Any ideas?
 
G

Guest

If I understand, ASP.Net looks up page's ViewState to re-populate(and set
controls) during post-back - hence, your dropDownList should contain the same
items list on the postback as it was populated during initial GET. If you
need to pass items from the client-side, I would suggest populating a hidden
field with on the client with all the items you need, and then reading them
on the server and manually re-populating your dropDown. You should also be
able to read the value in the dropDown with the code similar to the following:

Me.Request.Form(myDropDownList.UniqueID) ' in VB or
this.Request.Form[myDropDownList.UniqueID] ' in C#

This may be required as ASP.Net framework may not be able to match the value
from the Request object with the items loaded into your dropDownList from the
ViewState.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top