【发布时间】:2011-08-03 21:43:37
【问题描述】:
我正在使用 ASP.NET 4.0。我在同一页面上有 2 个DropDownList、一个CascadingDropDown(来自 Ajax Control Toolkit)和一个UpdatePanel。
下拉菜单不在更新面板中,它们的功能运行良好(一旦从 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 自己工作正常
DropDownLists 与级联下拉工作正常
当DropDownLists 与更新面板在同一页面上使用,但不在更新面板中时,更新面板停止工作?
【问题讨论】:
-
我看到你已经找到了错误的原因。请将您的发现作为对这个问题的答案发布并接受它作为答案。这样做可以帮助其他有同样问题的人。
标签: asp.net asp.net-ajax ajaxcontroltoolkit