tags:

views:

32

answers:

1

I have a drop down list on my page. The onchange event of this dropdownlist calls a web service using javascript/jquery. The webservice returns data that populates ANOTHER drop down list. When I do this and try to submit my form I get an invalid postback or callback error.

I know why it is occurring but cannot figure out how to stop this error. I found a few solutions about putting <pages enableEventValidation="false"/> in the web config. that is unfortunately not an option. Company doesn't allow it.

What may make it even trickier to solve is that these drop downs are all located in a control. Not it's own specific aspx page. Does anyone have any idea how to solve this?

Another thing that could make it trickier is that I have no idea what the ID of the control is. We use a framework here at work that gives the control added to the page some weird whacky ID when it gets added. Is this error even possible to avoid given all these constraints?

Thanks!

A: 

Have you considered making your second DropDownList that is filled dynamically a basic HTML select list instead of using a asp:DropDownList? You could then check the posted value server side manually although you would have to handle any PostBack refreshes.

To address your other point about the control, that is not really a problem if you are using a asp:DropDownList. You can just embed the ClientID in the javascript with:

$('#<%= yourDDL.ClientID %>')

Or you could assign it a unique class and use the class selector in JQuery:

$('.yourUniqueClassForTheDDL')

Hope that helps. If not, just leave a comment :)

Kelsey
Problem solved. I was tried the HtmlSelect and it was still throwing the error. But it was throwing the error because I was adding the HtmlSelect to a asp.net PlaceHolder. DOH! Thanks for the comment it definitely helped!
hanesjw