如果我们在页面中同时实现OnInit()和Page_Init怎么办? [英] What if we implement both OnInit() and Page_Init in a Page ?

查看:98
本文介绍了如果我们在页面中同时实现OnInit()和Page_Init怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我对ASP.NET页面生命周期事件有一点疑问。当我完成应用程序的编码时,我看到同时覆盖OnInit()方法和同一页面中的Page_Init事件。我认为这两种方法都有相同的目的,我看到的主要是覆盖OnInt()的实现,但不是两者。网络上的大多数文章都解释了这两种文章中更好的方法,但没有人解释如果我们在页面中实现这两种方法会发生什么。还解释在调用base.OnInit(e)之前和调用base.OnInit(e)之后编写一些代码之间的区别。这种情况意味着什么。有人可以帮我这个。







先谢谢。

解决方案

看看下面关于同一主题的讨论。



http://stackoverflow.com/questions/1255758/page-init-vs-oninit

Hi to all. I do have a small doubt regarding ASP.NET Page Life Cycle events. When I gone through the coding of an application i came to see both overriding of OnInit() method and also Page_Init event in same Page. I thought both the approaches serves the same purpose and I have seen mostly the implementation of overriden OnInt() only but not both. Most of the articles in the web explains about the better approach in these two but no one explained what happens if we implement both in a Page. Also explain what is the difference between writing some code before calling base.OnInit(e) and after calling base.OnInit(e). What does this situation means. Can anyone please help me regarding this.



Thanks in Advance.

解决方案

Have a look at below discussion on the same topic.

http://stackoverflow.com/questions/1255758/page-init-vs-oninit


这篇关于如果我们在页面中同时实现OnInit()和Page_Init怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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