DropDownList 第一次触发时总是进行全页回发

发布于 2024-08-25 21:58:14 字数 351 浏览 2 评论 0原文

我有一个使用 AJAX 库的 ASP.NET 页面。 UpdatePanel 内有一个下拉列表,在索引更改时应该更新不同的 UpdatePanel 以修改网格控件。

但是在页面首次出现后,您调整 ddl,整个页面回发,然后是(正确的)部分回发。在这一次之后,ddl 的所有其他使用都会正确执行,触发部分回发。

面板和 ddl 都是从代码添加的。 UP 是有条件更新且 ChildrenAsTriggers = true。下拉列表的 AutoPostBack 为 true,并且在 SelectedIndexChanged 上设置了一个事件。

那么这是怎么回事呢?我尝试过调整我能想到的所有设置,但页面仍然完全刷新一次,然后就可以正常工作了。

I have an ASP.NET page using the AJAX library. There is a dropdownlist inside an UpdatePanel, which on index changing is supposed to update a different UpdatePanel to modify a grid control.

But after the page first comes up, and you adjust the ddl, the entire page postbacks, followed by a (correct) partial postback. After this one time, every other usage of the ddl performs correctly, trigger partial postbacks.

Both the panel and the ddl are being added from code. The UP is Conditional updates and ChildrenAsTriggers = true. The dropdownlist is AutoPostBack true and has an event set up on SelectedIndexChanged.

So what is going on? I've tried adjusting every setting I can think of and still the page completely refreshes once, then works fine after that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗忘曾经 2024-09-01 21:58:14

我相信我已经解决了我目前在这个问题上的困境,尽管结果让我感觉有点愚蠢。当以编程方式添加下拉列表时,我没有给它一个 ID,假设 ASP.NET 无论如何都会为其分配一些顺序名称容器损坏的 ID。看来这就是原因。我假设最初的回发是由于 ASP.NET 试图处理缺少正确 ID 的情况,分配一个 ID,然后使用该 ID 进行部分回发。

或者也许根本上是完全不同的东西,但简单的解决方法是:向控件添加一个 ID。

I believe I've solved my current woes in regards to this problem, though I'm left feeling a bit dumb by the outcome. When programmatically adding the dropdownlist, I didn't give it an ID, assuming ASP.NET would just assign it some sequential name-container mangled ID anyway. It seems this was the cause. I'm assuming that the initial postback was due to ASP.NET trying to deal with the lack of a proper ID, assigning one, and then using that afterwards for the partial postbacks.

Or maybe it's something totally different at root, but the simple fix was: add an ID to the control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文