How do you retrieve a value from HTML in ASP.NET C#? I'm using a flat JSON file and fetching the data via Ajax and output the results with HTML. Normally this would work if you're using asp:ListItem.... tag. But I'm having trouble with retrieving the the value from the HTML tag upon form submission.
jQuery
$.ajax({
url: "js/covers.json",
dataType: "JSON",
success: function (data) {
var $select = $("#customCoversDD");
$select.empty().append('<option value="">- Please Select One -</option>');
$.each(data.custom, function (key, val) {
$select.append('<option id= "customCoversList" value="' + val.description + '">' + val.description + '</option>');
});
}
});
ASP.NET
<asp:RadioButton ID="customCover" Text="Custom Cover" GroupName="covers" runat="server"/>
<asp:DropDownList ID="customCoversDD" runat="server">
</asp:DropDownList>
C#
string coverChoice = "";
if (customCover.Checked)
{
coverChoice = customCoversDD.SelectedValue;
};