[英]How can I fire Selected Index Changed event without any postback using UpdatePanel?
I have a SignIn page that has a SignInUserControl page and is inside a MasterPage. 我有一个SignIn页面,该页面具有一个SignInUserControl页面,并且位于MasterPage内。 Inside the SignIn page I have 2 drop down lists
在“登录”页面中,我有2个下拉列表
ddlCountry
ddlCountry
ddlCity
ddlCity
I want to change the country and it automaticly load the cities. 我想更改国家,并自动加载城市。 Using this code:
使用此代码:
<li>
<label>Your Country:</label>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlCountry" runat="server" Width="356px"
DataTextField="Country" DataValueField="CodCountry"
OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack="true" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</li>
<li>
<label>Your City:</label>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlGestor" runat="server" Width="356px" DataTextField="City" DataValueField="CodCity" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</li>
the cities get loaded but AutoPostBack="True" calls the SignIn Page_Load(), the MasterPage Page_Load() and the SignInUserControl Page_Load(). 城市已加载,但是AutoPostBack =“ True”调用SignIn Page_Load(),MasterPage Page_Load()和SignInUserControl Page_Load()。 And by the way I have other functions inside these Page_Load(), so they are also being called
顺便说一下,我在这些Page_Load()中还有其他函数,因此它们也被称为
Is there any way to avoid this? 有什么办法可以避免这种情况? It seems like UpdatePanel is not a real Ajax because to work it has to send to the server all those pages and not only the block of code that I want
看来UpdatePanel不是真正的Ajax,因为要工作,它必须将所有这些页面发送到服务器,而不仅仅是我想要的代码块
yes you can achive it by using ajax cascading drop -down 是的,您可以使用Ajax级联下拉菜单来实现
by using it you can achive the binding without any postback firing up 通过使用它,您可以实现绑定而无需任何回发
follow up this link 跟进此链接
http://www.ajaxcontroltoolkit.com/CascadingDropDown/CascadingDropDown.aspx http://www.ajaxcontroltoolkit.com/CascadingDropDown/CascadingDropDown.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.