Valyrion
Valyrion

Reputation: 2603

How to fire dropdownlist's SelectedIndexChanged without postback?

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?

Upvotes: 0

Views: 12562

Answers (3)

mightysox
mightysox

Reputation: 21

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
            Your Stuff with OnSelectedIndexChanged in codebehind
        </ContentTemplate>
    </asp:UpdatePanel>

Rul easy

Upvotes: 2

Gavin Ward
Gavin Ward

Reputation: 1022

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

Upvotes: 1

Albireo
Albireo

Reputation: 11095

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

Upvotes: 0

Related Questions