Search code examples
asp.netupdatepanel

Update Panel doesn't refresh content


Problem:

I'm having problems with an UpdatePanel not refreshing its contents.

I have a web page with dropdown lists that cascade their selections such that selecting a value in one filters the available options in the next.

My page is structured like this:

  • DropDownList1
  • UpdatePanel1 ( DropDownList2 )
  • UpdatePanel2 ( DropDownList3 )

When the user makes a selection in DDL1, it filters the options in DDL2 and DDL3. this works

When the user makes a selection in DDL2, it should filter the remaining options in DDL3. does not work

What I've Tried:

I have several breakpoints set and I know that the update method for DDL3 is being called.

If i remove UpdatePanel2, the contents of DDL3 get updated as expected, but the whole page refreshes and scrolls back to the top.

UpdatePanel2 has an AsyncPostBackTrigger pointing to DDL2. If I change that to a PostBackTrigger DDL3 correctly updates but the whole page refreshes and scrolls back to the top.

If I remove all the Triggers from UpdatePanel2, then DDL3 correctly updates but the whole page refreshes and scrolls back to the top.

Help:

I don't know what else to try.


Solution

  • I fixed my problem.

    For whatever reason, the event handler wasn't getting set correctly. In the page init, I manually assigned the event handler and everything is working now.

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    
        AddHandler ddlSecond.SelectedIndexChanged, AddressOf ddlSecond_SelectedIndexChanged
    
    End Sub