在 page_load 中加载所述 ascx 控件时,在回发之间维护自定义控件 (ascx) 状态时出现问题

发布于 2024-08-09 07:27:45 字数 280 浏览 2 评论 0原文

我正在托管它的页面的 page_load 中加载自定义 ascx 控件。 这会造成各种回发问题。主要是,控件(文本框、下拉菜单等)状态在事件处理程序可以处理它们之前被重置。

有没有人有任何好的例子来说明我如何处理这个问题?

我的网站设计可以看到

在之前的问题中我被告知我可以让控件管理自己的状态。

I am loading a custom ascx control in page_load of the page that hosts it.
This creating all sorts of issues with postbacks. Mainly, control (textboxes, dropdowns,etc) states are getting reset before the event handlers can process them.

Does any one have any good examples of how I could handle this?

My site design can be seen here.

I've been told in a previous question that I can let the control manage its own state.

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

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

发布评论

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

评论(2

会傲 2024-08-16 07:27:45

这个问题已经被问过很多次了。看看这个例子:在验证器上设置 ControlToValidate

This has been asked so many times. Take a look at this for example: Setting the ControlToValidate on a Validator

ま昔日黯然 2024-08-16 07:27:45

视图状态在页面加载事件之前恢复,因此需要在页面加载事件之前加载动态控件并将其添加到页面,否则它们的状态将不会按您的预期恢复。请在 Init 事件中执行此操作。

Viewstate is restored before the page load event, and therefore dynamic controls need to be loaded and added to the page before the page load event or their state won't be restored as you expect. Do it in the Init event instead.

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