ASP.NET Page_Init两次被解雇! [英] ASP.NET Page_Init Fired Twice!

查看:168
本文介绍了ASP.NET Page_Init两次被解雇!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有AutoEventWireup =true,并在后面的

I have AutoEventWireup="true" and in my code behind

protected void Page_Init(object sender, EventArgs e)
{


}

当我调试,Page_Init方法被炒鱿鱼的两倍!

When I'm debugging, the Page_Init method is getting fired twice!

怎么回事?

推荐答案

让我们确保我们在这里介绍的基本知识:

Let's make sure we cover the basics here:

你有有服务器的事件您的页面上的任何控件?如果是这样,记得的每个的回传重新创建的整个页面。的因此,要处理一个事件是指运行的所有的的code的需要把页面连接在一起,包括你的初始化和负载的事件。

Do you have any controls on your page that have server events? If so, remember that every postback re-creates the entire page. So, to handle an event means running all of the code required put the page together, including your Init and Load events.

始终是两个有,不多不少。请求和响应。

Always two there are, no more no less. A request and a response.

这篇关于ASP.NET Page_Init两次被解雇!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆