如何在没有回发的情况下填充第二个下拉列表?

编程入门 行业动态 更新时间:2024-10-26 12:27:55
本文介绍了如何在没有回发的情况下填充第二个下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在一个页面中有很多下拉列表和文本框。我已经对文本框进行了验证。每个下拉列表都会填充另一个下拉列表。问题是,当selectedindexchanged事件被触发时,所有现有的验证消息都会消失。如何填充第二个下拉列表而不回发?

I have many dropdownlists and textboxes in a single page. I have done validations on textboxes. Each dropdownlist populate another dropdownlist. The problem is, all existing validation messages are disappear when selectedindexchanged event fired. How to populate second dropdownlist without postback?

推荐答案

您可以在页面中使用Updatepanel,这不会回发你的页。检查一下我用过它。 < asp:AsyncPostBackTrigger>中给出的ControlID是其索引更改的控件在第二个下拉列表中更改值。更新面板将应用于第二个下拉列表,其中必须反映值而不回发。在下面的示例中,年份下拉按照所选流程进行填充。 you can make use of Updatepanel in your page, this will not postback your page. Check this i have used it. The ControlID given in the <asp:AsyncPostBackTrigger> is the Control on whose indexchanging changes the values in the second dropdown. update panel is to be applied on the second dropdown where the values has to be reflected without postback. in the example below year dropdown gets filled as per the process selected. <asp:UpdatePanel ID="upSetSession" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddlyear" runat="server" AppendDataBoundItems="True" CssClass="textarea" ValidationGroup="validate"> <asp:ListItem>Please Select</asp:ListItem> </asp:DropDownList> <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validateyear" ControlToValidate="ddlyear" Display="Dynamic" ErrorMessage="*" ForeColor="#FF3300" ToolTip="*" ValidationGroup="validate">*</asp:CustomValidator> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlprocess" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel>

参考:没有postbac的级联下拉列表k [ ^ ]

使用ajax调用和Web方法,您可以使用回发绑定下拉列表 Using ajax call and Web Method you can bind dropdown wiht out postback

更多推荐

如何在没有回发的情况下填充第二个下拉列表?

本文发布于:2023-10-12 23:12:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486152.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第二个   情况下   如何在   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!