【问题标题】:Is there an ASP.NET event that occurs after postback, but before the page is destroyed/recreated?在回发之后但在页面被销毁/重新创建之前是否存在 ASP.NET 事件?
【发布时间】:2010-05-03 22:48:32
【问题描述】:

我的 ASP.NET 表单包含一组动态创建的单选按钮,这些单选按钮是在 Page_Load 事件处理程序中创建和配置的。

通常,我在 Page_Load 处理程序中处理回发数据,使用条件:

if (IsPostBack)

但是,由于我需要访问的控件是在 Page_Load 处理程序中创建的,因此之前页面呈现的回发数据会丢失。为了更好地说明问题,以下是事件发生时的概要:
1-Page_Load is invoked for the first time
2-An unknown number of radiobuttons are created dynamically
3-The radiobuttons are configured, based on information present on the server
4-The radiobuttons are added to the page's content
5-The user selects an option, and clicks the submit button
6-The Page_Load handler is invoked for the second time
7-The radio-buttons are added dynamically, exactly as before
8-The radio-button that the user checked is seemingly non-existant for processing

似乎我需要在不同的事件处理程序中处理不同的部分。回发后是否有事件发生,但原始单选按钮仍可访问?

【问题讨论】:

  • 覆盖 OnInit() 并在那里创建您的 RadioButtonList。然后,它们将在整个回发过程中都可以访问。
  • 你可以在 init 中构建你的控制结构吗?

标签: asp.net events forms post event-handling


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 2012-06-09
    • 2013-10-03
    • 1970-01-01
    相关资源
    最近更新 更多