SelectedIndexChanged を使用して AJAX Toolkit から CascadingDropDown を取得し、選択した値のクエリ文字列を渡すページにリダイレクトしました。元気いっぱいです!
ただし、ページに EnableEventValidation="false" を追加することによってのみ SelectedIndexChanged イベントが機能しました。問題は、CascadingDropDown が私の Web サイトの MasterPage に製品セレクターとして配置されることです。
EnableEventValidation="false" を MasterPage に追加したくありません。MSDN で ClientScriptManager.RegisterForEventValidation メソッドを見てきましたが、頭から離れません。
どうするのが一番いいですか?ClientScriptManager.RegisterForEventValidation を使用する簡単な例はありますか?
乾杯...
編集: コードは次のとおりです。
<asp:ScriptManager ID="asm" runat="server" />
<div>
Series: <asp:DropDownList ID="SeriesList" runat="server" /><br />
Printers: <asp:DropDownList ID="PrinterList" runat="server"
onselectedindexchanged="PrinterList_SelectedIndexChanged"
AutoPostBack="True" /><br />
</div>
<asp:CascadingDropDown ID="ccd1" runat="server"
ServicePath="CascadingDropdown1.cs.asmx" ServiceMethod="GetSeries"
TargetControlID="SeriesList" Category="Series"
PromptText="Select Series" />
<asp:CascadingDropDown ID="ccd2" runat="server"
ServicePath="CascadingDropdown1.cs.asmx" ServiceMethod="GetPrintersForSeries"
TargetControlID="PrinterList" ParentControlID="SeriesList" Category="Printer"
PromptText="Select Printer" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="PrinterList" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
そして、イベントは次のとおりです。
protected void PrinterList_SelectedIndexChanged(object sender, EventArgs e)
{
int printerID = Convert.ToInt32(PrinterList.SelectedValue);
System.Web.HttpContext.Current.Response.Redirect("Default.aspx?PID="+printerID);
}