1.aspx页面
A.) asp:dropdown ...onchange="javascriptfunctionname">
B.) <script>
Javascriptfunctionname
{
Getting dropdown selected values
}
</script>
C.) Problem Here:
How to pass drop down selected values in any c# method
D.) C# code
Public methodname
{
// NEED TO COMBO VALUES HERE ON CALLING ONCHANGE FUNCTION
}
请帮助指导。这非常重要,需要紧急完成。谢谢
答案 0 :(得分:0)
您可以在控件上使用回发,并且每次onchange命中时,它将回发到服务器,并且您可以在服务器端获得价值。
html
<asp:dropdownlist runat="server" autopostback="true" onselectedindexchanged="ddlTest_SelectedIndexChanged" id="ddlTest"> </asp:dropdownlist>
后面的代码
protected void ddlTest_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedText = ddlTest.SelectedItem.Text;
string selectedValue = ddlTest.SelectedItem.Value;
//--- Show results in page.
Response.Write("Selected Text is " + selectedText + " and selected value is :" + selectedValue);
}