我想将变量数据从js发送到我的aspx web表单
这是我的HTML
<select id="DDL_WorkCategory" class="form-control select2" multiple="multiple" data-placeholder="Select a Category" style="width: 100%;" onchange="myfunction();">
<option>نحت</option>
<option>خزف</option>
<option>تصميم</option>
<option>تصوير</option>
<option>تشكيل</option>
<option>ترمييم</option>
</select> <input type="hidden" ID="hidden_WorkCategory" runat="server" />
这是js
<script>
$("form").submit(function () {
GetSelectedValues();
});
function GetSelectedValues() {
var data = $("#DDL_WorkCategory").val();
alert(data);
var hiddenControl = '<%= hidden_WorkCategory.ClientID %>';
document.getElementById(hiddenControl).value = data;
}
</script>
这是css
protected void Submit_Click(object sender, EventArgs e)
{
string x = hidden_WorkCategory.Value;
}
字符串没有值仍然为空