I have a web form (with a master page, if that matters) with a select tag:
<select id="versionList" name="versionList""></select>
The options get dynamically appended with jQuery from a web service in response to a change event on another select control:
$.ajax ({
url: "service.asmx/GetVersions",
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{'productID':'" + productID + "' }",
dataType: "json",
success: function(versions) {
$("#versionList").empty();
$.each(versions.d, function() {
$("#versionList").append("<option value='" + this.ID + "'>" + this.Version + "</option>");
});
}
});
When I read the form variable during a post back, it returns "undefined":
string whereIsMyVersion = Request.Form["versionList"]; // "undefined"
I added a name
attribute to the select
element based on this question and expected to see the value of the option the user selected. Why do I get "undefined" instead?
If its relevant, I'm not using a DropDownList because it generates the error described here when I do the dynamic option appending.