After extensive research read about Script Manager and trial and error, this is what I found.
You can turn off event checking, but this is not always the best option, because both JavaScript and ASP.NET validation are good practices. This is the purpose of registering these values in the drop-down lists. If you have JavaScript that introduces options to your choice (select to display from an ASP.NET DropDownList control), you want to prevent Script injection when possible.
ANSWER MY QUESTION: To do this, we call it RegisterForEventValidation for EVERY possible value that may appear in this drop-down list for any possible situation in your application. In my case, I had two dropdowns. One drop-down menu used to create the postback and re-populate the second drop-down list with values based on the first drop-down list. However, now I use JavaScript to enter values into the drop-down list using jQuery.
Before re-populating the values, I delete all the values with jQuery.
jQuery("#<%=DDLTest.ClientID %>").children("option").each(function() { jQuery(this).remove(); });
When my first drop-down menu changes, I re-populate the second drop-down menu with values corresponding to the first drop-down value.
var map = { "1112": "Hair 5 Drug Panel", "1121": "Hair 5 Drug Panel and Extended Opiates Limit of Detection Test", "1120": "Hair 5 Drug Panel Limit of Detection Test" }; var thisTemp = this; // the reason I do this is because "this" is already being used in the callback. jQuery.each(map, function(key, val) { jQuery(thisTemp.Elements.DDLTest).append(jQuery("<option></option>").val(key).text(val)); });
And select the desired value.
jQuery(this.Elements.DDLTest).val(quickDataEntryObject.TestPricingOptionId);
However, before all this happens, I register the possible values for the drop-down list. You MUST do this in the Render event.
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) Dim testPricingOptionTable As DataTable = ApplicationContext.Database.ExecuteDataSet("procEventValidationRegisteredValues", "test_pricing_options").Tables(0) For Each testPricingOptionRow As DataRow In testPricingOptionTable.Rows Page.ClientScript.RegisterForEventValidation(DDLTest.UniqueID, testPricingOptionRow(0).ToString) Next MyBase.Render(writer) End Sub