Search code examples
c#asp.netjsonselectedvaluewebmethod

SelectedValue after updating dropdown with json/webmethod


I have a dropdown list to which items are added via a json/webmethod call - an "add new item to the box" type of solution. Now - this problem is, that if I select the new value, the _comobox1.SelectedValue is empty.

The controls are validated via a RequiredFieldValdiator so I am pretty sure that a value is indeed selected, and posted.

If I look at _comobox1.Items i even see the new item, with the correct value - any thoughts?


Solution

  • You must add this value to a hidden field and read it upon post. This is by design (and for security reasons) in asp.net web forms. I'm assuming you also turned off event validation just to enable this.

    See: http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/05a3e4bc-b39e-4165-b04f-c3af9332b578