如何在没有回发的情况下填充第二个下拉列表? [英] How to populate second dropdownlist without postback?

查看:48
本文介绍了如何在没有回发的情况下填充第二个下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个页面中有很多下拉列表和文本框。我已经对文本框进行了验证。每个下拉列表都会填充另一个下拉列表。问题是,当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


这篇关于如何在没有回发的情况下填充第二个下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆