【发布时间】:2010-05-03 22:48:32
【问题描述】:
我的 ASP.NET 表单包含一组动态创建的单选按钮,这些单选按钮是在 Page_Load 事件处理程序中创建和配置的。
通常,我在 Page_Load 处理程序中处理回发数据,使用条件:
if (IsPostBack)
但是,由于我需要访问的控件是在 Page_Load 处理程序中创建的,因此之前页面呈现的回发数据会丢失。为了更好地说明问题,以下是事件发生时的概要:1-Page_Load is invoked for the first time2-An unknown number of radiobuttons are created dynamically3-The radiobuttons are configured, based on information present on the server4-The radiobuttons are added to the page's content5-The user selects an option, and clicks the submit button6-The Page_Load handler is invoked for the second time7-The radio-buttons are added dynamically, exactly as before8-The radio-button that the user checked is seemingly non-existant for processing
似乎我需要在不同的事件处理程序中处理不同的部分。回发后是否有事件发生,但原始单选按钮仍可访问?
【问题讨论】:
-
覆盖 OnInit() 并在那里创建您的 RadioButtonList。然后,它们将在整个回发过程中都可以访问。
-
你可以在 init 中构建你的控制结构吗?
标签: asp.net events forms post event-handling