简体   繁体   English

更新面板不刷新内容

[英]Update Panel doesn't refresh content

Problem: 问题:

I'm having problems with an UpdatePanel not refreshing its contents. 我遇到了UpdatePanel无法刷新其内容的问题。

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 DropDownList1
  • UpdatePanel1 ( DropDownList2 ) UpdatePanel1(DropDownList2)
  • UpdatePanel2 ( DropDownList3 ) UpdatePanel2(DropDownList3)

When the user makes a selection in DDL1, it filters the options in DDL2 and DDL3. 当用户在DDL1中进行选择时,它将过滤DDL2和DDL3中的选项。 this works 这有效

When the user makes a selection in DDL2, it should filter the remaining options in DDL3. 用户在DDL2中进行选择时,应过滤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. 我设置了几个断点,而且我知道正在调用DDL3的更新方法。

If i remove UpdatePanel2, the contents of DDL3 get updated as expected, but the whole page refreshes and scrolls back to the top. 如果我删除UpdatePanel2,则DDL3的内容将按预期更新,但整个页面将刷新并滚动回到顶部。

UpdatePanel2 has an AsyncPostBackTrigger pointing to DDL2. UpdatePanel2具有指向DDL2的AsyncPostBackTrigger。 If I change that to a PostBackTrigger DDL3 correctly updates but the whole page refreshes and scrolls back to the top. 如果我将其更改为PostBackTrigger,则DDL3会正确更新,但整个页面都会刷新并滚动回到顶部。

If I remove all the Triggers from UpdatePanel2, then DDL3 correctly updates but the whole page refreshes and scrolls back to the top. 如果我从UpdatePanel2中删除所有触发器,则DDL3会正确更新,但整个页面都会刷新并滚动回到顶部。

Help: 救命:

I don't know what else to try. 我不知道还能尝试什么。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM