DropDownList's SelectedIndexChanged event not firing

前端 未结 7 709
一生所求
一生所求 2020-11-29 17:49

I have a DropDownList object in my web page. When I click on it and select a different value, nothing happens, even though I have a function wired up to the SelectedIn

相关标签:
7条回答
  • 2020-11-29 18:11

    Also make sure the page is valid. You can check this in the browsers developer tools (F12)

    In the Console tab select the correct Target/Frame and check for the [Page_IsValid] property

    If the page is not valid the form will not submit and therefore not fire the event.

    0 讨论(0)
  • 2020-11-29 18:13

    Set DropDownList AutoPostBack property to true.

    Eg:

    <asp:DropDownList ID="logList" runat="server" AutoPostBack="True" 
            onselectedindexchanged="itemSelected">
        </asp:DropDownList>
    
    0 讨论(0)
  • 2020-11-29 18:13

    try setting AutoPostBack="True" on the DropDownList.

    0 讨论(0)
  • 2020-11-29 18:13

    Instead of what you have written, you can write it directly in the SelectedIndexChanged event of the dropdownlist control, e.g.

    protected void ddlleavetype_SelectedIndexChanged(object sender, EventArgs e)
    {
     //code goes here
    }
    
    0 讨论(0)
  • 2020-11-29 18:21

    Add property ViewStateMode="Enabled" and EnableViewState="true" And AutoPostBack="true" in drop DropDownList

    0 讨论(0)
  • 2020-11-29 18:26

    For me answer was aspx page attribute, i added Async="true" to page attributes and this solved my problem.

    <%@ Page Language="C#" MasterPageFile="~/MasterPage/Reports.Master"..... 
        AutoEventWireup="true" Async="true" %>
    

    This is the structure of my update panel

    <div>
      <asp:UpdatePanel ID="updt" runat="server">
        <ContentTemplate>
    
          <asp:DropDownList ID="id" runat="server" AutoPostBack="true"        onselectedindexchanged="your server side function" />
    
       </ContentTemplate>
      </asp:UpdatePanel>
    </div>
    
    0 讨论(0)
提交回复
热议问题