How to fire dropdownlist's SelectedIndexChange

2019-09-06 02:57发布

I've got a DropDownList on my page databound to a query from my database (Databinding is set up only in my .aspx file, not in codebehind). Next to it I have a second DDL that gets populated from the SelectedIndexChanged function of the first one. This works, but only when AutoPostback is set to true.

Is there a way to fire the SelectedIndexChanged event or manually call this function in my codebehind without having to reload the page every time?

3条回答
走好不送
2楼-- · 2019-09-06 03:09

I would put the DDLs inside an AJAX UpdatePanel so it only updates that part of the page instead of a full page reload.

查看更多
走好不送
3楼-- · 2019-09-06 03:20
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
            Your Stuff with OnSelectedIndexChanged in codebehind
        </ContentTemplate>
    </asp:UpdatePanel>

Rul easy

查看更多
乱世女痞
4楼-- · 2019-09-06 03:27

Attach to the <select /> element's onChange event a JavaScript function, and do an AJAX request to a webservice.

查看更多
登录 后发表回答