How DropDownList's SelectedIndexChanged() works without PostBack?

我的未来我决定 提交于 2019-12-04 05:45:12
slfan

You could put the DropDownList into an <asp:UpdatePanel> and set AutoPostBack="true" on the DropDownList. You have to set the trigger to the SelectedIndexChanged event.

Something like this (don't forget the script manager)

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>
      <asp:DropDownList ID="drop1" runat="server" OnSelectedIndexChanged="ddlTablo_SelectedIndexChanged" />
   </ContentTemplate>
   <Triggers>
      <asp:AsyncPostbackTrigger ControlID="drop1" EventName="SelectedIndexChanged" />
   </Triggers>
</asp:UpdatePanel>

You can send ajax call, using asp.net UpdatePanel or use jQuery ajax. This wont do postback and your whole page wont get refreshed.

The UpdatePanel is quite straight forward and easy to use. ASP.net ajax will generate the asyn calls for you whereas jQuery ajax will probably need you to render html using javascript.

Vinoth Dexterity

In the code snippet below, add this parameter: AppendDataBoundItems="True"

<asp:DropDownList ID="ddlGroupNameFilter" 
    runat="server" 
    AutoPostBack="true" 
    AppendDataBoundItems="true" 
    OnSelectedIndexChanged="ddlLeadgroupName_SelectedIndexChange">
</asp:DropDownList>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!