簡體   English   中英

在下拉框中更改時調用Aspx.cs中的函數

[英]Calling a function in Aspx.cs with change in dropdownbox

我有一個頁面,在其中下拉列表中的值發生更改時,將通過下拉框中的相應文本來從數據庫中獲取值。

<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. 
} 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM