aspx 文件中的服务器端代码
我想问一下“用aspx文件编写的服务器端代码”是在控制执行生命周期的哪个阶段执行的?
是在SaveState之前还是之后,我声称它处于渲染阶段,是真的吗?
在 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>
对所做的更改将呈现但不会保存。 但是当将标记编写为
<asp:RadioButtonList ID="rdlistAnswers" runat="server" OnPreRender="loadMe"</asp:RadioButtonList>
-as loadMe 是 aspx.cs 文件中的事件处理程序方法时,会产生与上面的代码相同的效果 - 更改会被渲染并保存,因此当我在 PreRender 阶段进行更改时,状态会被保存,但是当我通过将逻辑放置在不保存的 aspx 文件中来做到这一点,这意味着 - 至少正如我所说 - 放置在 aspx 文件中的服务器端代码在渲染阶段执行,你同意我吗???
I want to ask in which phase of Control Execution Lifecycle is the "Server-Side-Code written in aspx file" being executed?
Is it before SaveState or after, I claim it's in the rendering phase, is it true??
in aspx file if my code writen as
"<%"
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???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接写入 aspx 文件内的代码将在 ASP.NET 页面生命周期中的渲染控制。
我测试了它预编译aspx文件和使用 Reflector 查看反编译代码。
Code written directly inside the aspx file will be executed at the end of Render Control in the ASP.NET page lifecycle.
I tested it precompiling an aspx file and using Reflector to look at the decompiled code.