C# 使用Javascript将该值设置为下拉列表,并在C中获取该值#
在C语言中,编码只显示空字符串(“”)C# 使用Javascript将该值设置为下拉列表,并在C中获取该值#,c#,javascript,C#,Javascript,在C语言中,编码只显示空字符串(“”) 如何获取下拉选择值?您正在更改下拉列表的html而不是视图状态,这就是为什么您没有进入asp.net服务器端code。您可以在某个隐藏字段中添加值,并在服务器端使用该值 HTML string res = DropDownList.SelectedValue; 这是网络表单吗?否则,您必须将select的值发布到服务器端应用程序以处理您的请求。 string res = DropDownList.SelectedValue; <i
如何获取下拉选择值?您正在更改
下拉列表的html
而不是视图状态
,这就是为什么您没有进入asp.net服务器端code
。您可以在某个隐藏字段中添加值,并在服务器端使用该值
HTML
string res = DropDownList.SelectedValue;
这是网络表单吗?否则,您必须将select的值发布到服务器端应用程序以处理您的请求。
string res = DropDownList.SelectedValue;
<input type="hidden" id="hdnDDL" runat="server" />
function SetDropDownValue() {
var opt = document.createElement("option");
opt.text = "New Value";
opt.value = "New Value";
document.getElementById('<%=DropDownList.ClientID%>').options.add(opt);
document.getElementById('<%=DropDownList.ClientID%>').value = val;
document.getElementById('<%=hdnDDL.ClientID%>').value = val;
}
string optionValue = hdnDDL.Value;