我正在使用ASP.NET 4.0。我在同一頁面上有2 DropDownList
,CascadingDropDown
(來自Ajax Control Toolkit)和UpdatePanel
。在同一aspx頁面上使用級聯下拉作爲更新面板
的下拉列表不更新面板內,它們的功能是工作的罰款(後一個選項是從一個DropDownList
選中,CascadingDropDown
就執行和更新第二DropDownList
)。
更新面板只包含一個按鈕和一個文本框。點擊按鈕後,會有一個事件處理程序來設置文本框上的文本。
當下拉菜單中的部分代碼被註釋掉時,更新面板可以正常工作,但一旦下拉列表未被註釋掉,單擊該按鈕不再刷新文本框,就不會發生回發。
aspx頁面:
<asp:ScriptManager ID="scriptManager" runat="server">
</asp:ScriptManager>
<div>
<label for="<%= ddOne.ClientID %>" >DD one</label>
<asp:DropDownList ID="ddOne" runat="server">
<asp:ListItem Text="" Value="-1" />
<asp:ListItem Text="Option one" Value="1" />
<asp:ListItem Text="Option two" Value="2" />
<asp:ListItem Text="Option three" Value="3" />
</asp:DropDownList>
</div>
<ajaxToolkit:CascadingDropDown
ID="ccdOne"
runat="server"
ParentControlID="ddOne"
TargetControlID="ddTwo"
Category="Category"
ServicePath="SomeWebService.asmx"
ServiceMethod="SomeWebMethod"
EmptyText="None available"
EmptyValue="-1"
LoadingText="Loading..." />
<div>
<label for="<%= ddTwo.ClientID %>">DD two</label>
<asp:DropDownList ID="ddTwo" runat="server">
</asp:DropDownList>
</div>
<asp:UpdatePanel runat="server" ID="upPanelOne">
<ContentTemplate>
<asp:Button ID="aButton" runat="server" Text="Click me" onclick="aButton_Click" />
<asp:TextBox ID="txtOne" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
背後的代碼:
protected void aButton_Click(object sender, EventArgs e)
{
txtOne.Text = "Hello world";
}
任何想法?
注:
UpdatePanel
精細
DropDownList
s的級聯自己的作品下拉正常工作
當同一頁面爲更新面板上的DropDownList
S,但不是在更新面板,更新面板停止工作?
我看到你找到了錯誤的原因。請發表你的發現作爲對這個問題的回答,並接受它作爲答案。這樣做可以幫助其他患有同樣問題的患者。 – rcdmk