ASP.NET validation issue - DropDownList being populated dynamically on client -


i'm populating dropdownlist using js on client , validating requiredfieldvalidator.

this works fine on client page.isvalid consistently comes false on server.

is because selected value wasn't in dropdownlist when first served page?

what's easiest way around this? (i need leave server validation turned on)

is because selected value wasn't in dropdownlist when first served page?

yes. you'll notice dropdownlist contain no items when postback, , yes, because you're adding items on client side. items add control on client totally unknown server. therefore, server validation fail, since field required.

in fact, adding items dynamically client script trigger eventvalidation complain there possible security problem, , you'll have had set enableeventvalidation false in <%@ page %> directive able post.

the best way around either

  1. generate items on server side, or

  2. not use server control (use regular non-asp.net select list) , manually validate on server looking @ posted values.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -