0
私のasp.netページにドロップダウンリストがあります。 選択したドロップダウン値に基づいてページにデータベースデータを表示したいとします。asp.netのAjaxベースのDropDownListイベント
どうすれば同じことができますか?
私のasp.netページにドロップダウンリストがあります。 選択したドロップダウン値に基づいてページにデータベースデータを表示したいとします。asp.netのAjaxベースのDropDownListイベント
どうすれば同じことができますか?
true
にAutoPostBackプロパティを設定した後、DropDownListをUpdatePanelに配置し、SelectedIndexChangedイベントにサブスクライブすることができます。
はここに例を示します
<%@ Page Language="C#" %>
<script type="text/C#" runat="server">
protected void OnChange(object sender, EventArgs e)
{
label.Text = string.Format("Selected value: {0}", ddl.SelectedValue);
}
</script>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form id="Form1" runat="server">
<asp:ScriptManager ID="scm" runat="server" />
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:DropDownList
ID="ddl"
runat="server"
AutoPostBack="true"
OnSelectedIndexChanged="OnChange">
<asp:ListItem Value="1" Text="item 1" />
<asp:ListItem Value="2" Text="item 2" />
<asp:ListItem Value="3" Text="item 3" />
</asp:DropDownList>
<asp:Label ID="label" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddl" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
あなたはfollowing articleを見ても、更新パネルおよびASP.NET AJAXの詳細については。
私はasp.netを初めて利用しています。あなたが同じように実装するのが簡単になるようにいくつかの便利なリンクを提供できますか? – Abhishek
私は例を掲載しました。次のリンクもご覧ください:http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx –