postback event error

  • Thread starter Thread starter Wendi Taranto
  • Start date Start date
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?
 
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
 
Back
Top