aspx文件中的服务器端代码

时间:2022-03-23 15:36:49

I want to ask in which phase of Control Execution Lifecycle is the "Server-Side-Code written in aspx file" being executed?

我想问一下控制执行生命周期的哪个阶段是“用aspx文件编写的服务器端代码”正在执行?

Is it before SaveState or after, I claim it's in the rendering phase, is it true??

是在SaveState之前还是之后,我声称它处于渲染阶段,是真的吗?

in aspx file if my code writen as

在aspx文件中如果我的代码写为

"<%"

if(true)
{
rdlistAnswers.Items.Clear();
foreach (string item in myCollection)
{
    i.Value = item;
    i.Text = item;
    rdlistAnswers.Items.Add(i);
}
"%>"
<asp:RadioButtonList ID="rdlistAnswers" runat="server"</asp:RadioButtonList>

the changes made to the are rendered but not saved. but when write the tag as

对其所做的更改已呈现但未保存。但是当把标签写成时

<asp:RadioButtonList ID="rdlistAnswers" runat="server" OnPreRender="loadMe"</asp:RadioButtonList>

-as loadMe is an event handler method in the aspx.cs file makes the same thing as code above- the changes are rendered and saved, so when I do changes in PreRender phase the state is saved but when I do it by placing the logic in the aspx file its not saved, this means -at least as I claim- that server-side code placed in aspx file executes in rendering phase, do you agree me???

-as loadMe是aspx.cs文件中的事件处理程序方法与上面的代码相同 - 更改被呈现并保存,因此当我在PreRender阶段进行更改时,状态会被保存,但是当我通过放置逻辑时在aspx文件中它没有保存,这意味着 - 至少我声称 - 放在aspx文件中的服务器端代码在渲染阶段执行,你同意我吗???

1 个解决方案

#1


Code written directly inside the aspx file will be executed at the end of Render Control in the ASP.NET page lifecycle.

直接在aspx文件中编写的代码将在ASP.NET页面生命周期中的Render Control结束时执行。

I tested it precompiling an aspx file and using Reflector to look at the decompiled code.

我测试了它预编译一个aspx文件并使用Reflector来查看反编译代码。

#1


Code written directly inside the aspx file will be executed at the end of Render Control in the ASP.NET page lifecycle.

直接在aspx文件中编写的代码将在ASP.NET页面生命周期中的Render Control结束时执行。

I tested it precompiling an aspx file and using Reflector to look at the decompiled code.

我测试了它预编译一个aspx文件并使用Reflector来查看反编译代码。