Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用dropdownbox中的更改调用Aspx.cs中的函数_C#_Asp.net_.net - Fatal编程技术网

C# 使用dropdownbox中的更改调用Aspx.cs中的函数

C# 使用dropdownbox中的更改调用Aspx.cs中的函数,c#,asp.net,.net,C#,Asp.net,.net,我有一个页面,在该页面中,下拉框中的值发生变化时,将在下拉框中传递相应的文本,以从数据库中获取值 <asp:DropDownList ID="dropid" runat="server" OnChange="Getvaluesfromaspx"></asp:DropDownList> 我希望从aspx文件调用aspx.cs中名为“Getvaluesfromaspx”的函数。 请提供帮助。使用“OnSelectedIndexChanged”事件而不是“OnChange

我有一个页面,在该页面中,下拉框中的值发生变化时,将在下拉框中传递相应的文本,以从数据库中获取值

<asp:DropDownList ID="dropid" runat="server" OnChange="Getvaluesfromaspx"></asp:DropDownList>

我希望从aspx文件调用aspx.cs中名为“Getvaluesfromaspx”的函数。 请提供帮助。

使用“OnSelectedIndexChanged”事件而不是“OnChange”事件

还将AutoPostBack属性值设置为true

<asp:DropDownList ID="dropid" AutoPostBack="true" runat="server" OnSelectedIndexChanged="Getvaluesfromaspx"></asp:DropDownList>
protected void Getvaluesfromaspx(object sender, EventArgs e)  
{  
    //Do whatever want to do here. 
}